unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 4880@emacsbugs.donarmstrong.com, "Per Starbäck" <per@starback.se>
Subject: bug#4880: point moves in other dired windows
Date: Fri, 04 Dec 2009 23:49:28 +0200	[thread overview]
Message-ID: <87k4x2xyd6.fsf@mail.jurta.org> (raw)
In-Reply-To: <87d42v8vhe.fsf@mail.jurta.org> (Juri Linkov's message of "Fri, 04 Dec 2009 01:54:05 +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/





  parent reply	other threads:[~2009-12-04 21:49 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 ` bug#4880: point moves in other dired windows Per Starbäck
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   ` Juri Linkov [this message]
2009-12-05  5:00     ` bug#4880: point moves in other dired windows 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87k4x2xyd6.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=4880@emacsbugs.donarmstrong.com \
    --cc=monnier@IRO.UMontreal.CA \
    --cc=per@starback.se \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).