[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: before-save-hook not run by 'compile'?

From: Eli Zaretskii
Subject: Re: before-save-hook not run by 'compile'?
Date: Fri, 05 Jan 2018 16:21:04 +0200

> From: Stephen Leake <address@hidden>
> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]