[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Two issues with the new Flymake
From: |
Stefan Monnier |
Subject: |
Re: Two issues with the new Flymake |
Date: |
Fri, 03 Nov 2017 08:33:59 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
[ Please report such problems via M-x report-emacs-bug, so they get
a bug-number. ]
> The first problem is something that happens when I add new code at the end of
> the source: if I write something and then quickly enough partially delete it
> with `delete-backward-char' and replace it with something else, at times
> Flymake reports an error message about unexpected report from the backend; I
> think it's due to the external checker reporting a problem in a region of the
> buffer that isn't there anymore at the time Flymake receives/processes that
> annotation. This is at worst a little annoyance, because at that time Emacs
> "hangs" for a noticeable interval of time, enough to disrupt my (re)writing.
What is the exact message you get?
> The second one is a strange interaction with the `python-shell-send-region' (a
> feature that I use very seldom): when I execute that, I get the following
> error message
> Error in post-command-hook (#[0
> "\304\305\303\242\306#\210r\302q\210\307\310\311\301\"\300\")\207" [nil
> (post-command on-display) #<killed buffer> (#0) remove-hook
> post-command-hook nil flymake-start remove post-command] 4]): (error
> "Selecting deleted buffer")
This #[...] thingy above is the
((start-post-command
()
(remove-hook 'post-command-hook #'start-post-command
nil)
(with-current-buffer buffer
(flymake-start (remove 'post-command deferred) force)))
function from flymake-start and the error comes from with-current-buffer
because `buffer` is not live any more when that code is run.
Not sure why that would happen, but here's my guess:
python-shell-send-region calls python-shell-buffer-substring
which does:
(with-temp-buffer
(python-mode)
[...]
so it generates a temp buffer, puts it in python-mode, which in turns
runs python-mode-hook and hence enables flymake-mode which then
registers itself on post-command-hook. But of course, by the time
post-command-hook is run, that temp buffer has been killed.
So I think the patch below should fix this. I pushed it to `emacs-26`.
Stefan
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 1048bc5065..649e954893 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -742,8 +742,9 @@ flymake-start
()
(remove-hook 'post-command-hook #'start-post-command
nil)
- (with-current-buffer buffer
- (flymake-start (remove 'post-command deferred) force)))
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (flymake-start (remove 'post-command deferred) force))))
(start-on-display
()
(remove-hook 'window-configuration-change-hook #'start-on-display