help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Automatically checking parentheses before a global save not working


From: Uday S Reddy
Subject: Re: Automatically checking parentheses before a global save not working.
Date: Wed, 08 Dec 2010 15:16:55 -0000
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Elena wrote:
On 1 Lug, 18:16, Andreas Politz <poli...@fh-trier.de> wrote:
                    (switch-to-buffer (buffer-name))
There is no user interaction at this point.

What do you mean, please? Can't I call `switch-to-buffer' there?
However, `yes-or-no-p' (which interacts with the user) works, and the
buffer to fix is being correctly identified by name.

All that is fine. But you can't expect to be able to edit the buffer in the midst of a save-buffer action. The best thing to would be to signal an error again, so that the save-buffer is aborted.


If I can't switch buffer right away, maybe an alternative and safe
approach would be to set a delayed switch, which would run after
termination of `condition-case'.

Also, I suppose running the hook is wrapped in some
current-buffer-saving-macro.

Andreas is wondering if save-buffer calls the before-save-hook inside a save-current-buffer macro, so that save-buffer finishes in the same buffer it started. If so, running switch-to-buffer in the middle of the hook will have no effect.

You might try printing an error message, e.g.,

  (error "Unbalanced parentheses in %s" (current-buffer))

Cheers,
Uday


reply via email to

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