emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#15329: closed (saveplace restores dired positions


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#15329: closed (saveplace restores dired positions to random places)
Date: Fri, 20 Dec 2013 20:23:01 +0000

Your message dated Fri, 20 Dec 2013 22:20:57 +0200
with message-id <address@hidden>
and subject line Re: bug#15329: saveplace restores dired positions to random 
places
has caused the debbugs.gnu.org bug report #15329,
regarding saveplace restores dired positions to random places
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
15329: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15329
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: saveplace restores dired positions to random places Date: Tue, 10 Sep 2013 23:45:15 +0300 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)
Tags: patch

Remembering dired positions is a good feature, but
unfortunately in its current implementation is useless.

The problem is that often the position of point in Dired
is restored to random places because in Dired buffers
it depends on many irrelevant ever-changing factors
such as the total size of all files in the directory
and available space (thus the line with this information
changes its length), sizes of each file above the restored
file in the Dired buffer also accounts to the incorrect position
of point, also added/deleted files in Dired change the restored
position to random places, different sorting order, etc.

An obvious solution to this problem is to save the
current file name in Dired instead of its point.

It seems saving information other than point doesn't contradict
the purpose of saveplace.el that automatically saves places where
visiting them later automatically moves point to the saved position.
Also elements of `save-place-alist' are (FILENAME . POSITION),
not more limited (FILENAME . POINT).  So saving a string to
POSITION would be consistent with the design of saveplace.el.

=== modified file 'lisp/saveplace.el'
--- lisp/saveplace.el   2013-06-14 09:32:01 +0000
+++ lisp/saveplace.el   2013-09-10 20:44:01 +0000
@@ -176,14 +178,17 @@ (defun save-place-to-alist ()
                    (not (string-match save-place-ignore-files-regexp
                                       item))))
       (let ((cell (assoc item save-place-alist))
-            (position (if (not (eq major-mode 'hexl-mode))
-                          (point)
-                        (with-no-warnings
-                          (1+ (hexl-current-address))))))
+            (position (cond ((eq major-mode 'hexl-mode)
+                            (with-no-warnings
+                              (1+ (hexl-current-address))))
+                           ((derived-mode-p 'dired-mode)
+                            (or (dired-get-filename nil t) (point)))
+                           (t (point)))))
         (if cell
             (setq save-place-alist (delq cell save-place-alist)))
         (if (and save-place
-                 (not (= position 1)))  ;; Optimize out the degenerate case.
+                 (not (and (integerp position)
+                          (= position 1)))) ;; Optimize out the degenerate 
case.
             (setq save-place-alist
                   (cons (cons item position)
                         save-place-alist)))))))
@@ -298,7 +304,8 @@ (defun save-place-find-file-hook ()
     (if cell
        (progn
          (or revert-buffer-in-progress-p
-             (goto-char (cdr cell)))
+             (and (integerp (cdr cell))
+                  (goto-char (cdr cell))))
           ;; and make sure it will be saved again for later
           (setq save-place t)))))
 
@@ -309,7 +318,10 @@ (defun save-place-dired-hook ()
     (if cell
         (progn
           (or revert-buffer-in-progress-p
-              (goto-char (cdr cell)))
+              (cond ((integerp (cdr cell))
+                    (goto-char (cdr cell)))
+                   ((stringp (cdr cell))
+                    (dired-goto-file (cdr cell)))))
           ;; and make sure it will be saved again for later
           (setq save-place t)))))
 



--- End Message ---
--- Begin Message --- Subject: Re: bug#15329: saveplace restores dired positions to random places Date: Fri, 20 Dec 2013 22:20:57 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)
> I realized now that the current format is completely backward-compatible.
> When `find-file-hook' restores the saved position in a file, it doesn't see
> the dired entries (that end with a directory separator) in the new format.

Karl, due to the imminent feature freeze I had to commit the patch now.
Please revert it if you don't agree with this implementation.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]