GNU bug report logs - #4880
point moves in other dired windows

Previous Next

Package: emacs;

Reported by: Per Starbäck <per <at> starback.se>

Date: Fri, 6 Nov 2009 15:45:04 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

Full log


Message #15 received at 4880 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Per Starbäck <per <at> starback.se>,
        4880 <at> debbugs.gnu.org
Subject: Re: bug#4880: point moves in other dired windows
Date: Fri, 04 Dec 2009 23:49:28 +0200
> Unfortunately, this doesn't work for dired buffers that are
> not displayed in a window.  This is a really annoying problem.

What about the following patch that also restores buffer's point positions
after dired-revert in hidden dired buffers?

Index: lisp/dired.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired.el,v
retrieving revision 1.446
diff -c -r1.446 dired.el
*** lisp/dired.el	4 Dec 2009 05:00:44 -0000	1.446
--- lisp/dired.el	4 Dec 2009 21:49:19 -0000
***************
*** 1143,1161 ****
  ;; 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)."
!   (mapcar (lambda (w)
! 	    (list w
! 		  (with-selected-window w
! 		    (dired-get-filename nil t))
! 		  (window-point w)))
! 	  (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)
        (unless (and (nth 1 win-file-pos)
  		   (dired-goto-file (nth 1 win-file-pos)))
  	(goto-char (nth 2 win-file-pos))
--- 1170,1211 ----
  ;; Some of these are also used when inserting subdirs.
  
  (defun dired-save-positions ()
!   "Return the current positions in all buffers and windows with this directory.
! The positions have the form (BUFFER-POSITIONS WINDOW-POSITIONS).
! 
! BUFFER-POSITIONS are positions in all dired buffers associated with
! the current directory.  The buffer positions 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
!    (mapcar (lambda (buffer)
! 	     (cons buffer
! 		   (with-current-buffer buffer
! 		     (list
! 		      (dired-get-filename nil t)
! 		      (point)))))
! 	   (dired-buffers-for-dir
! 	    (if (consp dired-directory) (car dired-directory) dired-directory)))
!    (mapcar (lambda (w)
! 	     (list w
! 		   (with-selected-window w
! 		     (dired-get-filename nil t))
! 		   (window-point w)))
! 	   (get-buffer-window-list nil 0 t))))
  
  (defun dired-restore-positions (positions)
    "Restore POSITIONS saved with `dired-save-positions'."
!   (dolist (buf-file-pos (nth 0 positions))
!     (with-current-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))
!     (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))

-- 
Juri Linkov
http://www.jurta.org/emacs/



This bug report was last modified 15 years and 145 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.