From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: before-save-hook not run by 'compile'? Date: Fri, 05 Jan 2018 16:21:04 +0200 Message-ID: <83y3lc9yjz.fsf@gnu.org> References: <86fu7o8iz1.fsf@stephe-leake.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1515162019 26857 195.159.176.226 (5 Jan 2018 14:20:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 5 Jan 2018 14:20:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 05 15:20:15 2018 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 1eXSqx-0006Sa-Gj for ged-emacs-devel@m.gmane.org; Fri, 05 Jan 2018 15:20:11 +0100 Original-Received: from localhost ([::1]:42517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXSsw-00089d-S3 for ged-emacs-devel@m.gmane.org; Fri, 05 Jan 2018 09:22:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXSsN-000895-82 for emacs-devel@gnu.org; Fri, 05 Jan 2018 09:21:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXSsI-0000hJ-7l for emacs-devel@gnu.org; Fri, 05 Jan 2018 09:21:39 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXSsI-0000hB-3t; Fri, 05 Jan 2018 09:21:34 -0500 Original-Received: from [176.228.60.248] (port=4882 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eXSsG-0003tG-86; Fri, 05 Jan 2018 09:21:33 -0500 In-reply-to: <86fu7o8iz1.fsf@stephe-leake.org> (message from Stephen Leake on Tue, 02 Jan 2018 07:53:54 -0600) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:221618 Archived-At: > From: Stephen Leake > Date: Tue, 02 Jan 2018 07:53:54 -0600 > > I have 'delete-trailing-whitespace' in 'before-save-hook'; the Ada > compiler I'm using complains if there is trailing whitespace. > > However, sometimes when I edit a file and then invoke 'compile', the > file is save, but 'delete-trailing-whitespace' is _not_ run. > > If I invoke 'save-some-buffers' directly, 'delete-trailing-whitespace' > is run. > > I'm running emacs-26, built from the branch. > > I've looked thru the code for compile, and it appears to call > 'save-buffer', which appears to run the hook. That call to 'before-save-hook' is made under some condition, so maybe that condition is false in those cases? Also, the hook is run with-demoted-errors, so maybe it signals an error before actually doing its job? > I've tried to instrument save-buffer for edebug, but then running > 'compile' crashes emacs (with no helpful messages). You could put a hook in write-contents-functions that just announced itself to some special buffer, and then see whether it is called on those cases where before-save-hook seems not to work. The hooks in write-contents-functions are called immediately after before-save-hook, so they could be evidence for whether before-save-hook ran normally.