Skip to content

Commit e44a49e

Browse files
authored
Fix: unblanace ) (#315)
* fix ) and tests * need to bump version for the fix
1 parent 96a7981 commit e44a49e

5 files changed

Lines changed: 28 additions & 29 deletions

File tree

HISTORY.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
** Main branch change
55

6-
** 1.73
6+
** 1.74
77
- Fix: Guard eat/ghostel process filters against deleted buffers on exit and add regression tests
88
- Fix: Enable ghostel full-redraw mode for Claude Code and Copilot CLI sessions
99
- Refactor: Use Ghostel public API for sending input

ai-code-backends-infra-eat.el

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,17 @@ variables for the terminal process."
134134
(set-process-filter
135135
proc
136136
(lambda (process output)
137-
(when-let ((buf (process-buffer process)))
138-
(when (buffer-live-p buf)
139-
(let ((filtered-output
140-
(with-current-buffer buf
141-
(ai-code-backends-infra--strip-alternate-screen-sequences output))))
142-
(when orig-filter
143-
(funcall orig-filter process filtered-output))
144-
(when (buffer-live-p buf)
145-
(with-current-buffer buf
146-
(when (ai-code-backends-infra--output-meaningful-p filtered-output)
147-
(ai-code-backends-infra--note-meaningful-output))
148-
(ai-code-session-link--linkify-recent-output filtered-output)))))))))))
137+
(when (buffer-live-p buffer)
138+
(let ((filtered-output
139+
(with-current-buffer buffer
140+
(ai-code-backends-infra--strip-alternate-screen-sequences output))))
141+
(when orig-filter
142+
(funcall orig-filter process filtered-output))
143+
(when (buffer-live-p buffer)
144+
(with-current-buffer buffer
145+
(when (ai-code-backends-infra--output-meaningful-p filtered-output)
146+
(ai-code-backends-infra--note-meaningful-output))
147+
(ai-code-session-link--linkify-recent-output filtered-output)))))))))
149148
(cons buffer (get-buffer-process buffer)))))
150149

151150
(provide 'ai-code-backends-infra-eat)

ai-code-backends-infra-ghostel.el

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,20 @@ variables for the terminal process."
105105
(let ((default-directory working-dir)
106106
(proc (ai-code-backends-infra--start-ghostel-process buffer command)))
107107
(when (processp proc)
108-
(set-process-query-on-exit-flag proc nil)
108+
(ignore-errors
109+
(set-process-query-on-exit-flag proc nil))
109110
(let ((orig-filter (process-filter proc)))
110111
(set-process-filter
111112
proc
112113
(lambda (process output)
113-
(when-let ((buf (process-buffer process)))
114-
(when (buffer-live-p buf)
115-
(when orig-filter
116-
(funcall orig-filter process output))
117-
(when (buffer-live-p buf)
118-
(with-current-buffer buf
119-
(when (ai-code-backends-infra--output-meaningful-p output)
120-
(ai-code-backends-infra--note-meaningful-output))
121-
(ai-code-session-link--linkify-recent-output output)))))))))
114+
(when (buffer-live-p buffer)
115+
(when orig-filter
116+
(funcall orig-filter process output))
117+
(when (buffer-live-p buffer)
118+
(with-current-buffer buffer
119+
(when (ai-code-backends-infra--output-meaningful-p output)
120+
(ai-code-backends-infra--note-meaningful-output))
121+
(ai-code-session-link--linkify-recent-output output))))))))
122122
(cons buffer proc)))))
123123

124124
(provide 'ai-code-backends-infra-ghostel)

ai-code-change.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,13 @@ ARG is the prefix argument for clipboard context."
363363
(format "Selected region starting on line %d"
364364
region-start-line)))))
365365
(files-context-string (ai-code--get-context-files-string))
366-
(repo-context-string (ai-code--format-repo-context-info))
366+
(region-comment-block-p (or (not region-text)
367+
(ai-code--is-comment-block region-text)))
367368
;; Validate scenario before prompting user
368369
(_ (unless (or region-text is-comment)
369370
(user-error "Current line is not a TODO comment and cannot proceed with `ai-code-implement-todo'. Please select a TODO comment (not DONE), a region of comments, or activate on a blank line")))
371+
(_ (unless region-comment-block-p
372+
(user-error "Selected region must be a comment block")))
370373
(action-intent (completing-read "Select action: "
371374
'("Code change" "Ask question")
372375
nil t))
@@ -391,16 +394,12 @@ ARG is the prefix argument for clipboard context."
391394
(initial-input
392395
(cond
393396
((and ask-question-p region-text)
394-
(unless (ai-code--is-comment-block region-text)
395-
(user-error "Selected region must be a comment block"))
396397
(format "Regarding this TODO comment block in the selected region:\n%s\n%s%s%s"
397398
region-location-line region-text function-context files-context-string))
398399
((and ask-question-p is-comment)
399400
(format "Regarding this TODO comment on line %d: '%s'%s%s"
400401
current-line-number current-line function-context files-context-string))
401402
(region-text
402-
(unless (ai-code--is-comment-block region-text)
403-
(user-error "Selected region must be a comment block"))
404403
(format
405404
"Please implement code for this requirement comment block in the selected region first. After implementing, keep the comment in place and ensure it begins with a DONE prefix (change TODO to DONE or prepend DONE if no prefix). If this is a pure new code block, place it after the comment; otherwise keep the existing structure and make corresponding change for the context.\n%s\n%s%s%s"
406405
region-location-line region-text function-context
@@ -409,6 +408,7 @@ ARG is the prefix argument for clipboard context."
409408
(format "Please implement code for this requirement comment on line %d: '%s' first. After implementing, keep the comment in place and ensure it begins with a DONE prefix (change TODO to DONE or prepend DONE if needed). If this is a pure new code block, place it after the comment; otherwise keep the existing structure and make corresponding change for the context.%s%s"
410409
current-line-number current-line function-context files-context-string))
411410
(t "")))
411+
(repo-context-string (ai-code--format-repo-context-info))
412412
(prompt (ai-code-read-string prompt-label initial-input))
413413
(final-prompt
414414
(concat prompt

ai-code.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;;; ai-code.el --- Unified interface for AI coding backends such as Codex CLI, Copilot CLI, Claude Code, Gemini CLI, Opencode, Grok CLI, etc -*- lexical-binding: t; -*-
22

33
;; Author: Kang Tu <tninja@gmail.com>
4-
;; Version: 1.73
4+
;; Version: 1.74
55
;; Package-Requires: ((emacs "29.1") (transient "0.9.0") (magit "2.1.0"))
66
;; URL: https://github.com/tninja/ai-code-interface.el
77

0 commit comments

Comments
 (0)