[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: eval-last-sexp narrows buffer on error
From: |
martin rudalics |
Subject: |
Re: eval-last-sexp narrows buffer on error |
Date: |
Sun, 29 Apr 2007 11:31:20 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
> Calling `eval-last-sexp' on:
> "\u"
> correctly causes the error "Non-hex digit used for Unicode escape", but
> unexpectedly leaves the buffer narrowed to point-min and point.
It's a problem with `save-restriction'. Take:
(with-current-buffer (get-buffer-create "*foo*")
(delete-region (point-min) (point-max))
(insert "foo\nbar\nfoo\n")
(save-restriction
(narrow-to-region (line-beginning-position -1) (line-end-position -1))
(error "????")))
It will leave the buffer narrowed although the doc-string of
`save-restriction' says:
The old restrictions settings are restored
even in case of abnormal exit (throw or error).
AFAICT Emacs 20 DTRT here, Emacs 21 and 22 don't. Could you try to
debug it?
You can side-step the problem with something like
(with-current-buffer (get-buffer-create "*foo*")
(delete-region (point-min) (point-max))
(insert "foo\nbar\nfoo\n")
(condition-case err
(save-restriction
(narrow-to-region (line-beginning-position -1) (line-end-position -1))
(error "????"))
(error
err
(widen)
(error (error-message-string err)))))
which does the wrong thing when the buffer was already narrowed before
executing the `save-restriction' form.