emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110425: * lisp/window.el (internal--


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110425: * lisp/window.el (internal--before-save-selected-window)
Date: Sun, 07 Oct 2012 11:54:30 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110425
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sun 2012-10-07 11:54:30 -0400
message:
  * lisp/window.el (internal--before-save-selected-window)
  (internal--after-save-selected-window): New functions extracted from
  save-selected-window.  Make sure we return the `alist' we construct.
  (save-selected-window): Use them.
  * lisp/textmodes/tex-mode.el (tex-recenter-output-buffer):
  Use with-selected-window.
modified:
  lisp/ChangeLog
  lisp/textmodes/tex-mode.el
  lisp/window.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-10-07 15:15:16 +0000
+++ b/lisp/ChangeLog    2012-10-07 15:54:30 +0000
@@ -1,5 +1,13 @@
 2012-10-07  Stefan Monnier  <address@hidden>
 
+       * window.el (internal--before-save-selected-window)
+       (internal--after-save-selected-window): New functions extracted from
+       save-selected-window.  Make sure we return the `alist' we construct.
+       (save-selected-window): Use them.
+
+       * textmodes/tex-mode.el (tex-recenter-output-buffer):
+       Use with-selected-window.
+
        * emacs-lisp/autoload.el (make-autoload): Add `cl-defmacro' to the
        forms that define macros (bug#12593).
 

=== modified file 'lisp/textmodes/tex-mode.el'
--- a/lisp/textmodes/tex-mode.el        2012-09-30 03:10:13 +0000
+++ b/lisp/textmodes/tex-mode.el        2012-10-07 15:54:30 +0000
@@ -2565,8 +2565,7 @@
     (if (null tex-shell)
        (message "No TeX output buffer")
       (setq window (display-buffer tex-shell))
-      (save-selected-window
-       (select-window window)
+      (with-selected-window window
        (bury-buffer tex-shell)
        (goto-char (point-max))
        (recenter (if linenum

=== modified file 'lisp/window.el'
--- a/lisp/window.el    2012-10-05 05:57:24 +0000
+++ b/lisp/window.el    2012-10-07 15:54:30 +0000
@@ -28,6 +28,35 @@
 
 ;;; Code:
 
+(defun internal--before-save-selected-window ()
+  (cons (selected-window)
+        ;; We save and restore all frames' selected windows, because
+        ;; `select-window' can change the frame-selected-window of
+        ;; whatever frame that window is in.  Each text terminal's
+        ;; top-frame is preserved by putting it last in the list.
+        (apply #'append
+               (mapcar (lambda (terminal)
+                         (let ((frames (frames-on-display-list terminal))
+                               (top-frame (tty-top-frame terminal))
+                               alist)
+                           (if top-frame
+                               (setq frames
+                                     (cons top-frame
+                                           (delq top-frame frames))))
+                           (dolist (f frames)
+                             (push (cons f (frame-selected-window f))
+                                   alist))
+                           alist))
+                       (terminal-list)))))
+
+(defun internal--after-save-selected-window (state)
+  (dolist (elt (cdr state))
+    (and (frame-live-p (car elt))
+         (window-live-p (cdr elt))
+         (set-frame-selected-window (car elt) (cdr elt) 'norecord)))
+  (when (window-live-p (car state))
+    (select-window (car state) 'norecord)))
+
 (defmacro save-selected-window (&rest body)
   "Execute BODY, then select the previously selected window.
 The value returned is the value of the last form in BODY.
@@ -44,34 +73,11 @@
 order of recently selected windows and the buffer list ordering
 are not altered by this macro (unless they are altered in BODY)."
   (declare (indent 0) (debug t))
-  `(let ((save-selected-window-window (selected-window))
-        ;; We save and restore all frames' selected windows, because
-        ;; `select-window' can change the frame-selected-window of
-        ;; whatever frame that window is in.  Each text terminal's
-        ;; top-frame is preserved by putting it last in the list.
-        (save-selected-window-alist
-         (apply 'append
-                (mapcar (lambda (terminal)
-                          (let ((frames (frames-on-display-list terminal))
-                                (top-frame (tty-top-frame terminal))
-                                alist)
-                            (if top-frame
-                                (setq frames
-                                      (cons top-frame
-                                            (delq top-frame frames))))
-                            (dolist (f frames)
-                              (push (cons f (frame-selected-window f))
-                                    alist))))
-                        (terminal-list)))))
+  `(let ((save-selected-window--state (internal--before-save-selected-window)))
      (save-current-buffer
        (unwind-protect
           (progn ,@body)
-        (dolist (elt save-selected-window-alist)
-          (and (frame-live-p (car elt))
-               (window-live-p (cdr elt))
-               (set-frame-selected-window (car elt) (cdr elt) 'norecord)))
-        (when (window-live-p save-selected-window-window)
-          (select-window save-selected-window-window 'norecord))))))
+         (internal--after-save-selected-window save-selected-window--state)))))
 
 (defvar temp-buffer-window-setup-hook nil
   "Normal hook run by `with-temp-buffer-window' before buffer display.


reply via email to

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