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


View this message in rfc822 format

From: help-debbugs <at> gnu.org (Emacs bug Tracking System)
To: Per Starbäck <per <at> starback.se>
Subject: bug#4880 closed by Stefan Monnier <monnier <at> IRO.UMontreal.CA> (Re:
 bug#4880: point moves in other dired windows)
Date: Thu, 12 Nov 2009 22:45:04 +0000
[Message part 1 (text/plain, inline)]
This is an automatic notification regarding your bug report
which was filed against the emacs package:

#4880: point moves in other dired windows

It has been closed by Stefan Monnier <monnier <at> IRO.UMontreal.CA>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Stefan Monnier <monnier <at> IRO.UMontreal.CA> by
replying to this email.


-- 
4880: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4880
Emacs Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Per Starbäck <per <at> starback.se>
Subject: Re: bug#4880: point moves in other dired windows
Date: Thu, 12 Nov 2009 17:38:51 -0500
> dired-revert saves the old point, but only for the current window. The
> enclosed patch fixes it so that dired-revert saves and restores the
> point in all windows showing that dired buffer.

Thank you, installed,


        Stefan
[Message part 3 (message/rfc822, inline)]
From: Per Starbäck <per <at> starback.se>
To: bug-gnu-emacs <at> gnu.org
Subject: point moves in other dired windows
Date: Fri, 6 Nov 2009 16:35:32 +0100
I have done this in 23.1 and in the current cvs version:

emacs -q /tmp
C-x 2 g

Point in the *other* window now goes to the beginning of the buffer,
which was unexpected for me.

dired-revert saves the old point, but only for the current window. The
enclosed patch fixes it so that
dired-revert saves and restores the point in all windows showing that
dired buffer.

$ diff -c dired.el.~1.436~ dired.el
*** dired.el.~1.436~	2009-11-06 13:29:08.000000000 +0100
--- dired.el	2009-11-06 15:35:29.000000000 +0100
***************
*** 1103,1110 ****
  Preserves old cursor, marks/flags, hidden-p."
    (widen)				; just in case user narrowed
    (let ((modflag (buffer-modified-p))
! 	(opoint (point))
! 	(ofile (dired-get-filename nil t))
  	(mark-alist nil)		; save marked files
  	(hidden-subdirs (dired-remember-hidden))
  	(old-subdir-alist (cdr (reverse dired-subdir-alist))) ; except pwd
--- 1103,1109 ----
  Preserves old cursor, marks/flags, hidden-p."
    (widen)				; just in case user narrowed
    (let ((modflag (buffer-modified-p))
! 	(positions (dired-save-positions))
  	(mark-alist nil)		; save marked files
  	(hidden-subdirs (dired-remember-hidden))
  	(old-subdir-alist (cdr (reverse dired-subdir-alist))) ; except pwd
***************
*** 1124,1132 ****
      ;; ... run the hook for the whole buffer, and only after markers
      ;; have been reinserted (else omitting in dired-x would omit marked files)
      (run-hooks 'dired-after-readin-hook)	; no need to narrow
!     (or (and ofile (dired-goto-file ofile)) ; move cursor to where it
! 	(goto-char opoint))		; was before
!     (dired-move-to-filename)
      (save-excursion			; hide subdirs that were hidden
        (dolist (dir hidden-subdirs)
  	(if (dired-goto-subdir dir)
--- 1123,1129 ----
      ;; ... run the hook for the whole buffer, and only after markers
      ;; have been reinserted (else omitting in dired-x would omit marked files)
      (run-hooks 'dired-after-readin-hook)	; no need to narrow
!     (dired-restore-positions positions)
      (save-excursion			; hide subdirs that were hidden
        (dolist (dir hidden-subdirs)
  	(if (dired-goto-subdir dir)
***************
*** 1140,1145 ****
--- 1137,1161 ----
  ;; Subroutines of dired-revert
  ;; Some of these are also used when inserting subdirs.

+ (defun dired-save-positions ()
+   "Store the current positions in all windows displaying this dired buffer.
+ Store both filename (if any) and 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))
+ 	(dired-move-to-filename)))))
+
  (defun dired-remember-marks (beg end)
    "Return alist of files and their marks, from BEG to END."
    (if selective-display			; must unhide to make this work.



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.