Last active
February 28, 2025 18:36
-
-
Save kickingvegas/9c33e97d62054ea3523732459f8bef25 to your computer and use it in GitHub Desktop.
Workaround fix for dired-movement-style bug https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76596
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun eli/dired--move-to-next-line (arg jumpfun) | |
(let ((wrapped nil) | |
(old-arg arg) | |
(old-position (progn | |
;; It's always true that we should move | |
;; to the filename when possible. | |
(dired-move-to-filename) | |
(point))) | |
;; Up/Down indicates the direction. | |
(moving-down (if (cl-plusp arg) | |
1 ; means Down. | |
-1))) ; means Up. | |
;; Line by line in case we forget to skip empty lines. | |
(while (not (zerop arg)) | |
(funcall jumpfun moving-down) | |
(when (= old-position (point)) | |
;; Now point is at beginning/end of movable area, | |
;; but it still wants to move farther. | |
(cond | |
;; `cycle': go to the other end. | |
((eq dired-movement-style 'cycle) | |
;; Argument not changing on the second wrap | |
;; means infinite loop with no files found. | |
(if (and wrapped (eq old-arg arg)) | |
(setq arg 0) | |
(goto-char (if (cl-plusp moving-down) | |
(point-min) | |
(point-max)))) | |
(setq wrapped t)) | |
;; `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)) | |
(not (zerop arg))) | |
(funcall jumpfun (- moving-down)) | |
;; Point not moving means infinite loop. | |
(if (= old-position (point)) | |
(setq arg 0) | |
(setq old-position (point)))) | |
;; Encountered a boundary, so let's stop movement. | |
(setq arg (if (and (dired-between-files) | |
(not (dired-get-subdir))) | |
0 moving-down))))) | |
(unless (and (dired-between-files) (not (dired-get-subdir))) | |
;; Has moved to a non-empty line. This movement does | |
;; make sense. | |
(cl-decf arg moving-down)) | |
(setq old-position (point))))) | |
(advice-add #'dired--move-to-next-line :override #'eli/dired--move-to-next-line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Workaround fix for Emacs 30.1 bug provided by Eli Zaretskii https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76596 where
dired-movement-style
does not honor subdirs.Remove this on next release of Emacs.