aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-15 23:07:37 -0500
committerCraig Jennings <c@cjennings.net>2026-06-15 23:08:00 -0500
commitb53375c12c46f7020feae0c6274770ef2e31ebbb (patch)
treef011843b136ba240635dfd31e666734536203984 /modules
parent5b83e9a224115ecc86332db8c14104e7b0864bef (diff)
downloaddotemacs-b53375c12c46f7020feae0c6274770ef2e31ebbb.tar.gz
dotemacs-b53375c12c46f7020feae0c6274770ef2e31ebbb.zip
fix(dirvish): mark-all-visible no longer skips every other file
dired-mark advances point itself, so the loop's extra forward-line skipped every other file (and could mark a directory). Use dired-get-filename + file-directory-p with an if/else: a marked file line advances once via dired-mark, non-file/directory lines advance manually. Replaces the regex line predicate (retired with its mock test) with a real-Dired marked-count test.
Diffstat (limited to 'modules')
-rw-r--r--modules/dirvish-config.el24
1 files changed, 8 insertions, 16 deletions
diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el
index e2fc19f1d..8b672764b 100644
--- a/modules/dirvish-config.el
+++ b/modules/dirvish-config.el
@@ -204,28 +204,20 @@ used by `cj/dirvish-open-html-in-eww'."
;;; ------------------------ Dired Mark All Visible Files -----------------------
-(defun cj/--dired-line-is-directory-p (line)
- "Return non-nil when LINE is a Dired listing of a directory.
-
-Dired prefixes each file line with a one-character mark column followed
-by `ls -l' output, so a directory line reads as `<mark> drwx...' (mark,
-space, `d'). Header lines (` /path/to:'), `total N' lines, and empty
-lines all fail this match.
-
-Pure helper used by `cj/dired-mark-all-visible-files'."
- (and line (string-match-p "\\`. d" line)))
-
(defun cj/dired-mark-all-visible-files ()
"Mark all visible files in Dired mode."
(interactive)
(save-excursion
(goto-char (point-min))
(while (not (eobp))
- (let ((line (buffer-substring-no-properties
- (line-beginning-position) (line-end-position))))
- (unless (cj/--dired-line-is-directory-p line)
- (dired-mark 1)))
- (forward-line 1))))
+ ;; dired-mark advances point itself, so only advance manually on the
+ ;; lines it isn't called for (directories, headers, totals). Use
+ ;; dired-get-filename to identify real file lines; it returns nil on
+ ;; non-file lines (no error with the second arg).
+ (let ((fn (dired-get-filename nil t)))
+ (if (and fn (not (file-directory-p fn)))
+ (dired-mark 1)
+ (forward-line 1))))))
;;; ------------------------ Dirvish Duplicate File Copy ------------------------