all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Per Starbäck" <per@starback.se>
To: bug-gnu-emacs@gnu.org
Subject: bug#4880: point moves in other dired windows
Date: Fri, 6 Nov 2009 16:35:32 +0100	[thread overview]
Message-ID: <912155b0911060735o6f81038hcc5927f21c119700@mail.gmail.com> (raw)

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.






             reply	other threads:[~2009-11-06 15:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <jwv639fs71y.fsf-monnier+emacsbugreports@gnu.org>
2009-11-06 15:35 ` Per Starbäck [this message]
2009-11-12 22:45   ` bug#4880: marked as done (point moves in other dired windows) Emacs bug Tracking System
     [not found] ` <87d42v8vhe.fsf@mail.jurta.org>
2009-12-04 21:49   ` bug#4880: point moves in other dired windows Juri Linkov
2009-12-05  5:00     ` Stefan Monnier
2009-12-05 19:42       ` Juri Linkov
2009-12-05 21:09         ` Stefan Monnier
2009-12-05 23:22           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=912155b0911060735o6f81038hcc5927f21c119700@mail.gmail.com \
    --to=per@starback.se \
    --cc=4880@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.