[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 75a1d00: Fixed bug#19576: `write-file' saves wron
From: |
Anders Lindgren |
Subject: |
[Emacs-diffs] emacs-25 75a1d00: Fixed bug#19576: `write-file' saves wrong buffer. |
Date: |
Fri, 20 Nov 2015 20:10:09 +0000 |
branch: emacs-25
commit 75a1d009f747a220c7b9b1cfdbe7077082fe02d6
Author: Anders Lindgren <address@hidden>
Commit: Anders Lindgren <address@hidden>
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.
---
lisp/follow.el | 55 ++++++++++++++++++++++++++-----------------------------
1 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/lisp/follow.el b/lisp/follow.el
index 57ba2f6..37de923 100644
--- a/lisp/follow.el
+++ b/lisp/follow.el
@@ -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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-25 75a1d00: Fixed bug#19576: `write-file' saves wrong buffer.,
Anders Lindgren <=