From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: Two issues with the new Flymake
Date: Fri, 03 Nov 2017 08:33:59 -0400 [thread overview]
Message-ID: <jwvr2tfpnip.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 87k1z7adxi.fsf@metapensiero.it
[ 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
next prev parent reply other threads:[~2017-11-03 12:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-03 9:50 Two issues with the new Flymake Lele Gaifax
2017-11-03 12:33 ` Stefan Monnier [this message]
2017-11-03 14:07 ` Lele Gaifax
2017-11-03 16:59 ` João Távora
2017-11-03 17:15 ` Stefan Monnier
2017-11-03 20:17 ` Three Flymake backends Was " João Távora
2017-11-04 15:30 ` Stefan Monnier
2017-11-04 23:17 ` João Távora
2017-11-05 12:50 ` Dmitry Gutov
2017-11-05 12:59 ` João Távora
2017-11-05 13:04 ` Dmitry Gutov
2017-11-05 13:22 ` João Távora
2017-11-05 20:14 ` Dmitry Gutov
2017-11-05 21:05 ` João Távora
2017-11-05 23:56 ` Dmitry Gutov
2017-11-06 9:48 ` João Távora
2017-11-06 10:35 ` Dmitry Gutov
2017-11-06 11:08 ` João Távora
2017-11-13 0:23 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvr2tfpnip.fsf-monnier+gmane.emacs.devel@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).