From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Two issues with the new Flymake Date: Fri, 03 Nov 2017 08:33:59 -0400 Message-ID: References: <87k1z7adxi.fsf@metapensiero.it> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1509712609 16030 195.159.176.226 (3 Nov 2017 12:36:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 3 Nov 2017 12:36:49 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 03 13:36:46 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAbDF-0003Zv-8b for ged-emacs-devel@m.gmane.org; Fri, 03 Nov 2017 13:36:41 +0100 Original-Received: from localhost ([::1]:36518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAbDM-0008JY-N3 for ged-emacs-devel@m.gmane.org; Fri, 03 Nov 2017 08:36:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAbBA-0007A5-83 for emacs-devel@gnu.org; Fri, 03 Nov 2017 08:34:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAbB5-0000M6-De for emacs-devel@gnu.org; Fri, 03 Nov 2017 08:34:30 -0400 Original-Received: from [195.159.176.226] (port=37147 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eAbB5-0000Lv-74 for emacs-devel@gnu.org; Fri, 03 Nov 2017 08:34:27 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eAbAg-0001Ya-S8 for emacs-devel@gnu.org; Fri, 03 Nov 2017 13:34:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 72 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:1Jkpyy69Vp41h46Wl2A7OMsi/wI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:219884 Archived-At: [ 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) # (#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