[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: switch-to-buffer in hack-local-variables and hack-one-local-variable
From: |
Stefan Monnier |
Subject: |
Re: switch-to-buffer in hack-local-variables and hack-one-local-variable |
Date: |
Fri, 06 May 2005 09:25:35 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
> Both `hack-local-variables' and `hack-one-local-variable' may call
> `switch-to-buffer' when parsing local variables. As a consequence, a
> "save-window-excursion: Cannot switch buffers in a dedicated window"
> error is generated when calling `find-file-noselect' while the
> selected window is dedicated. Replacing `switch-to-buffer' with
> `pop-to-buffer' resolves the problem for me.
Would the patch below suit you?
> Alternatively, the approach from `hack-local-variables-prop-line' might
> be used.
That's pretty ugly. I'd rather use pop-to-buffer.
Any objection against this patch?
Stefan
--- orig/lisp/files.el
+++ mod/lisp/files.el
@@ -2198,17 +2195,11 @@
(eq enable-local-variables t)
(and enable-local-variables
(save-window-excursion
- (condition-case nil
- (switch-to-buffer (current-buffer))
- (error
- ;; If we fail to switch in the selected window,
- ;; it is probably a minibuffer.
- ;; So try another window.
- (condition-case nil
- (switch-to-buffer-other-window
(current-buffer))
- (error
- (switch-to-buffer-other-frame
(current-buffer))))))
- (y-or-n-p (format "Set local variables as specified
in -*- line of %s? "
+ (let ((pop-up-frames nil))
+ ;; Refrain from popping up frames since it can't
+ ;; be undone by save-window-excursion.
+ (pop-to-buffer (current-buffer)))
+ (y-or-n-p (format "Set local variables as
specified in -*- line of %s? "
(file-name-nondirectory
buffer-file-name)))))))
(let ((enable-local-eval enable-local-eval))
(while result
@@ -2242,7 +2233,10 @@
mode-only
(and enable-local-variables
(save-window-excursion
- (switch-to-buffer (current-buffer))
+ (let ((pop-up-frames nil))
+ ;; Refrain from popping up frames since it
+ ;; can't be undone by save-window-excursion.
+ (pop-to-buffer (current-buffer)))
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
@@ -2475,7 +2469,10 @@
(or (eq enable-local-eval t)
(and enable-local-eval
(save-window-excursion
- (switch-to-buffer (current-buffer))
+ (let ((pop-up-frames nil))
+ ;; Refrain from popping up frames since it
+ ;; can't be undone by save-window-excursion.
+ (pop-to-buffer (current-buffer)))
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))