From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Per =?UTF-8?Q?Starb=C3=A4ck?= Newsgroups: gmane.emacs.bugs Subject: bug#4880: point moves in other dired windows Date: Fri, 6 Nov 2009 16:35:32 +0100 Message-ID: <912155b0911060735o6f81038hcc5927f21c119700@mail.gmail.com> Reply-To: Per =?UTF-8?Q?Starb=C3=A4ck?= , 4880@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1257522459 17875 80.91.229.12 (6 Nov 2009 15:47:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Nov 2009 15:47:39 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 06 16:47:32 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N6R2B-0004pl-HO for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Nov 2009 16:47:31 +0100 Original-Received: from localhost ([127.0.0.1]:49526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6R2B-0007pK-20 for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Nov 2009 10:47:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N6R25-0007p7-Mc for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:47:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N6R20-0007oW-9g for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:47:24 -0500 Original-Received: from [199.232.76.173] (port=46377 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6R20-0007oT-4c for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:47:20 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:47866) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N6R1z-0000wd-HW for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:47:19 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nA6FlGvC029312; Fri, 6 Nov 2009 07:47:16 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nA6Fj4tr029005; Fri, 6 Nov 2009 07:45:04 -0800 Resent-Date: Fri, 6 Nov 2009 07:45:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Per =?UTF-8?Q?Starb=C3=A4ck?= Original-Sender: per.starback@gmail.com Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Fri, 06 Nov 2009 15:45:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 4880 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125752174228520 (code B ref -1); Fri, 06 Nov 2009 15:45:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 6 Nov 2009 15:35:42 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nA6FZfmk028517 for ; Fri, 6 Nov 2009 07:35:42 -0800 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N6Qqi-0006nD-JE for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:35:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N6Qqd-0006mH-Ct for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:35:39 -0500 Original-Received: from [199.232.76.173] (port=52015 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6Qqd-0006mE-81 for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:35:35 -0500 Original-Received: from mail-bw0-f215.google.com ([209.85.218.215]:48493) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N6Qqc-00072C-Ne for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2009 10:35:35 -0500 Original-Received: by bwz7 with SMTP id 7so1343729bwz.26 for ; Fri, 06 Nov 2009 07:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=2IyxjscXnzAEYUv+5Hf72pf/0sVIP2x3rFwKOyEQ7Z0=; b=xznsjV7apc14M1GUBrLsPHR+6S0MgjpQQjdgg+czLOoZUX3cwZI2GYn5XZawLcv39F QbNRWLx551lop7U0QgON0PGMujN2iQxQpvTpvPawt7IeINnCgvAbJZRzcpxh+mSEP8TD wY+XqOr3zPII/wkHCYkrpkvTFXrjxqb1wx3RM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=UKLltNGECRdhDEHCLqCgoHOJ+ZE4fFLlId02tlc4Aa8jgX9ZPdajTaNch9Q1UE6FBj xNGjomjDUUjot0gxEXKSj1K8mTObnx3ex6NLVx2OOGeFQnp7mfQ8bPfn18aLTHVmomsL ux2m5UDKi8YWF28OzgSiTnAlqScpH2PjfFtB0= Original-Received: by 10.223.3.85 with SMTP id 21mr575092fam.98.1257521732510; Fri, 06 Nov 2009 07:35:32 -0800 (PST) X-Google-Sender-Auth: 864f0c4d6f8f1d3c X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Fri, 06 Nov 2009 10:47:24 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32450 Archived-At: 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.