]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a choice to 'dired-movement-style' to restore the previous behavior
authorJuri Linkov <juri@linkov.net>
Sun, 23 Mar 2025 17:48:28 +0000 (19:48 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 25 Mar 2025 18:17:37 +0000 (19:17 +0100)
* lisp/dired.el (dired-movement-style): Add new values
'bounded-files' and 'cycle-files' (bug#76596).
(dired--move-to-next-line): Use new values for users
who prefer the default behavior of Emacs 30.1.

(cherry picked from commit bc51fabc108ceccd4824ba6c6f0c29f143ebf47a)

lisp/dired.el

index b6f4236bcf3804575e3e973d2e743298e63cd5c0..2cb81f0bd5cd64e80efcf7baaf8dcc028cab9659 100644 (file)
@@ -510,10 +510,14 @@ Possible non-nil values:
               to the first/last visible line.
  * `bounded': don't move up/down if the current line is the
               first/last visible line.
+ * `cycle-files': like `cycle' but moves only over file lines.
+ * `bounded-files': like `bounded' but moves only over file lines.
 Any other non-nil value is treated as `bounded'."
   :type '(choice (const :tag "Move to any line" nil)
                  (const :tag "Cycle through non-empty lines" cycle)
-                 (const :tag "Stop on last/first non-empty line" bounded))
+                 (const :tag "Cycle through file lines" cycle-files)
+                 (const :tag "Stop on last/first non-empty line" bounded)
+                 (const :tag "Stop on last/first file line" bounded-files))
   :group 'dired
   :version "30.1")
 
@@ -2921,7 +2925,7 @@ is controlled by `dired-movement-style'."
         ;; but it still wants to move farther.
         (cond
          ;; `cycle': go to the other end.
-         ((eq dired-movement-style 'cycle)
+         ((memq dired-movement-style '(cycle cycle-files))
           ;; Argument not changing on the second wrap
           ;; means infinite loop with no files found.
           (if (and wrapped (eq old-arg arg))
@@ -2933,7 +2937,8 @@ is controlled by `dired-movement-style'."
          ;; `bounded': go back to the last non-empty line.
          (dired-movement-style ; Either 'bounded or anything else non-nil.
           (while (and (dired-between-files)
-                      (not (dired-get-subdir))
+                      (or (eq dired-movement-style 'bounded-files)
+                          (not (dired-get-subdir)))
                       (not (zerop arg)))
             (funcall jumpfun (- moving-down))
             ;; Point not moving means infinite loop.
@@ -2942,9 +2947,12 @@ is controlled by `dired-movement-style'."
               (setq old-position (point))))
           ;; Encountered a boundary, so let's stop movement.
           (setq arg (if (and (dired-between-files)
-                             (not (dired-get-subdir)))
+                             (or (eq dired-movement-style 'bounded-files)
+                                 (not (dired-get-subdir))))
                         0 moving-down)))))
-      (unless (and (dired-between-files) (not (dired-get-subdir)))
+      (unless (and (dired-between-files)
+                   (or (memq dired-movement-style '(cycle-files bounded-files))
+                       (not (dired-get-subdir))))
         ;; Has moved to a non-empty line.  This movement does
         ;; make sense.
         (decf arg moving-down))