mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-24 19:03:29 +00:00
Fixed bug#19576: `write-file' saves wrong buffer.
If a function on the hook `window-size-change-functions' doesn't restore the current buffer, functions that save and restore the current window configuration (like `y-or-no-p') could silently change the current buffer. When `write-file' asked the user confirmation to overwrite a file, `y-or-no-p' changed the current buffer, and the wrong buffer was saved to the file. * lisp/follow.el (follow-windows-start-end): Call `select-frame' using the `norecord' parameter. (follow-window-size-change): Restore current buffer. Call `select-frame' using the `norecord' parameter. Cleanup.
This commit is contained in:
parent
eb3f6754b4
commit
75a1d009f7
@ -865,10 +865,10 @@ Note that this handles the case when the cache has been set to nil."
|
||||
(let ((orig-win (selected-window))
|
||||
win-start-end)
|
||||
(dolist (w windows)
|
||||
(select-window w)
|
||||
(select-window w 'norecord)
|
||||
(push (cons w (cons (window-start) (follow-calc-win-end)))
|
||||
win-start-end))
|
||||
(select-window orig-win)
|
||||
(select-window orig-win 'norecord)
|
||||
(setq follow-windows-start-end-cache (nreverse win-start-end)))))
|
||||
|
||||
(defsubst follow-pos-visible (pos win win-start-end)
|
||||
@ -1416,33 +1416,30 @@ non-first windows in Follow mode."
|
||||
"Redraw all windows in FRAME, when in Follow mode."
|
||||
;; Below, we call `post-command-hook'. Avoid an infloop.
|
||||
(unless follow-inside-post-command-hook
|
||||
(let ((buffers '())
|
||||
(orig-window (selected-window))
|
||||
(orig-buffer (current-buffer))
|
||||
(orig-frame (selected-frame))
|
||||
windows
|
||||
buf)
|
||||
(select-frame frame)
|
||||
(unwind-protect
|
||||
(walk-windows
|
||||
(lambda (win)
|
||||
(setq buf (window-buffer win))
|
||||
(unless (memq buf buffers)
|
||||
(set-buffer buf)
|
||||
(when follow-mode
|
||||
(setq windows (follow-all-followers win))
|
||||
(if (not (memq orig-window windows))
|
||||
(follow-redisplay windows win)
|
||||
;; Make sure we're redrawing around the selected
|
||||
;; window.
|
||||
(select-window orig-window)
|
||||
(follow-post-command-hook)
|
||||
(setq orig-window (selected-window)))
|
||||
(setq buffers (cons buf buffers)))))
|
||||
'no-minibuf)
|
||||
(select-frame orig-frame)
|
||||
(set-buffer orig-buffer)
|
||||
(select-window orig-window)))))
|
||||
(save-current-buffer
|
||||
(let ((orig-frame (selected-frame)))
|
||||
(select-frame frame)
|
||||
(let ((picked-window (selected-window)) ; Note: May change below.
|
||||
(seen-buffers '()))
|
||||
(unwind-protect
|
||||
(walk-windows
|
||||
(lambda (win)
|
||||
(let ((buf (window-buffer win)))
|
||||
(unless (memq buf seen-buffers)
|
||||
(set-buffer buf)
|
||||
(when follow-mode
|
||||
(let ((windows (follow-all-followers win)))
|
||||
(if (not (memq picked-window windows))
|
||||
(follow-redisplay windows win)
|
||||
;; Make sure we're redrawing around the selected
|
||||
;; window.
|
||||
(select-window picked-window 'norecord)
|
||||
(follow-post-command-hook)
|
||||
(setq picked-window (selected-window))))
|
||||
(push buf seen-buffers)))))
|
||||
'no-minibuf)
|
||||
(select-window picked-window 'norecord)))
|
||||
(select-frame orig-frame)))))
|
||||
|
||||
(add-hook 'window-scroll-functions 'follow-avoid-tail-recenter t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user