Skip to content

Commit

Permalink
Emacs: fix logging when merlin call is interrupted
Browse files Browse the repository at this point in the history
Currently, "interrupted" is only logged when the result parsing is
interrupted (by C-g), but it seems pretty clear that the original
intent (and more useful behavior) was to log "interrupted" when the
actual merlin call was interrupted.

We do this by setting up separate condition handlers for (1) the
result parse failing; and (2) the merlin call or result parse being
interrupted.
  • Loading branch information
bcc32 committed Jun 16, 2023
1 parent efd8a46 commit 4d654ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ unreleased
==========
+ merlin binary
- Handle concurrent server start (#1622)
+ editor modes
- emacs: call merlin-client-logger with "interrupted" if the
merlin binary itself is interrupted, not just the parsing of the
result (#1626).


merlin 4.9
Expand Down
19 changes: 11 additions & 8 deletions emacs/merlin.el
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,19 @@ argument (lookup appropriate binary, setup logging, pass global settings)"

(defun merlin-call (command &rest args)
"Execute a command and parse output: return an sexp on success or throw an error"
(let* ((binary (merlin-command))
(result (merlin--call-merlin command args)))
(let ((binary (merlin-command)) result)
(condition-case err
(setq result (car (read-from-string result)))
(error
(merlin-client-logger binary command -1 "failure")
(error "merlin: error %s trying to parse answer: %s"
err result))
(progn
(setq result (merlin--call-merlin command args))
(condition-case err
(setq result (car (read-from-string result)))
(error
(merlin-client-logger binary command -1 "failure")
(error "merlin: error %s trying to parse answer: %s"
err result))))
(quit
(merlin-client-logger binary command -1 "interrupted")))
(merlin-client-logger binary command -1 "interrupted")
(signal (car err) (cdr err))))
(let* ((notifications (cdr-safe (assoc 'notifications result)))
(timing (cdr-safe (assoc 'timing result)))
(class (cdr-safe (assoc 'class result)))
Expand Down

0 comments on commit 4d654ce

Please sign in to comment.