emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/lisp ChangeLog dired.el


From: Juri Linkov
Subject: [Emacs-diffs] emacs/lisp ChangeLog dired.el
Date: Sat, 05 Dec 2009 23:22:07 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Juri Linkov <jurta>     09/12/05 23:22:07

Modified files:
        lisp           : ChangeLog dired.el 

Log message:
        Save and restore dired buffer's point positions too.  (Bug#4880)
        
        (dired-save-positions): Return in the first element
        buffer's position in format (BUFFER DIRED-FILENAME BUFFER-POINT).
        Doc fix.
        (dired-restore-positions): First restore buffer's position.
        While restoring window's positions, check if window still displays
        the original buffer.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16834&r2=1.16835
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/dired.el?cvsroot=emacs&r1=1.447&r2=1.448

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16834
retrieving revision 1.16835
diff -u -b -r1.16834 -r1.16835
--- ChangeLog   5 Dec 2009 22:01:00 -0000       1.16834
+++ ChangeLog   5 Dec 2009 23:22:03 -0000       1.16835
@@ -1,3 +1,14 @@
+2009-12-05  Juri Linkov  <address@hidden>
+
+       Save and restore dired buffer's point positions too.  (Bug#4880)
+
+       * dired.el (dired-save-positions): Return in the first element
+       buffer's position in format (BUFFER DIRED-FILENAME BUFFER-POINT).
+       Doc fix.
+       (dired-restore-positions): First restore buffer's position.
+       While restoring window's positions, check if window still displays
+       the original buffer.
+
 2009-12-05  Chong Yidong  <address@hidden>
 
        * bindings.el (complete-symbol): Call semantic-ia-complete-symbol

Index: dired.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired.el,v
retrieving revision 1.447
retrieving revision 1.448
diff -u -b -r1.447 -r1.448
--- dired.el    4 Dec 2009 21:45:34 -0000       1.447
+++ dired.el    5 Dec 2009 23:22:07 -0000       1.448
@@ -1169,23 +1169,40 @@
 ;; Some of these are also used when inserting subdirs.
 
 (defun dired-save-positions ()
-  "Return the current positions in all windows displaying this dired buffer.
-The positions have the form (WINDOW FILENAME POINT)."
+  "Return current positions in the buffer and all windows with this directory.
+The positions have the form (BUFFER-POSITION WINDOW-POSITIONS).
+
+BUFFER-POSITION is the point position in the current dired buffer.
+The buffer position have the form (BUFFER DIRED-FILENAME BUFFER-POINT).
+
+WINDOW-POSITIONS are current positions in all windows displaying
+this dired buffer.  The window positions have the form (WINDOW
+DIRED-FILENAME WINDOW-POINT)."
+  (list
+   (list (current-buffer) (dired-get-filename nil t) (point))
   (mapcar (lambda (w)
            (list w
                  (with-selected-window w
                    (dired-get-filename nil t))
                  (window-point w)))
-         (get-buffer-window-list nil 0 t)))
+          (get-buffer-window-list nil 0 t))))
 
 (defun dired-restore-positions (positions)
   "Restore POSITIONS saved with `dired-save-positions'."
-  (dolist (win-file-pos positions)
-    (with-selected-window (car win-file-pos)
+  (let* ((buf-file-pos (nth 0 positions))
+        (buffer (nth 0 buf-file-pos)))
+    (unless (and (nth 1 buf-file-pos)
+                (dired-goto-file (nth 1 buf-file-pos)))
+      (goto-char (nth 2 buf-file-pos))
+      (dired-move-to-filename))
+    (dolist (win-file-pos (nth 1 positions))
+      ;; Ensure that window still displays the original buffer.
+      (when (eq (window-buffer (nth 0 win-file-pos)) buffer)
+       (with-selected-window (nth 0 win-file-pos)
       (unless (and (nth 1 win-file-pos)
                   (dired-goto-file (nth 1 win-file-pos)))
        (goto-char (nth 2 win-file-pos))
-       (dired-move-to-filename)))))
+           (dired-move-to-filename)))))))
 
 (defun dired-remember-marks (beg end)
   "Return alist of files and their marks, from BEG to END."




reply via email to

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