From: Eli Zaretskii <eliz@gnu.org>
To: Stephen Leake <stephen_leake@stephe-leake.org>
Cc: emacs-devel@gnu.org
Subject: Re: before-save-hook not run by 'compile'?
Date: Fri, 05 Jan 2018 16:21:04 +0200 [thread overview]
Message-ID: <83y3lc9yjz.fsf@gnu.org> (raw)
In-Reply-To: <86fu7o8iz1.fsf@stephe-leake.org> (message from Stephen Leake on Tue, 02 Jan 2018 07:53:54 -0600)
> From: Stephen Leake <stephen_leake@stephe-leake.org>
> 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.
prev parent reply other threads:[~2018-01-05 14:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 13:53 before-save-hook not run by 'compile'? Stephen Leake
2018-01-05 14:21 ` Eli Zaretskii [this message]
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=83y3lc9yjz.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=stephen_leake@stephe-leake.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).