bug#81612: 32.0.50; setting marks in dired-hidden directories creates garbled output

Daniel Clemente <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <CAJKAhPAtRk2ms09gBzYm_a_3ZKQMwxTosUhXHwGrQGwdin9Z4Q@mail.gmail.com>
Reproduce in "emacs -Q":
1. C-x C-f /etc RET to open a folder in dired
2. Press $ to hide the folder. It contracts everything into a line
3. Press m to mark the files at point

Result: screen text is garbled. You see a long line like
  /etc:*  drwxr-xr-x 222 root  root      20480 Aug 12 17:39 .*
drwxr-xr-x  24 root  root       4096 Aug  5 01:49 ..*  -rw-r--r--   1
root  root      12823 Dec 23  2024 a2ps.cfg*  -rw-r--r--   1 root
root       2502 Dec 23  2024 a2ps-site.cfg*  drwxr-xr-x   3 root  root
      4096 Aug  5 17:52 acpi*  -rw-r--r--   1 root  root       3981
May  7  2025 adduser.conf*  -rw-r--r--   1 root  root       2981 Feb
28  2023 adduser.conf.update-old*  -rw-r--r--   1 root  root
46 […]


I think it's because dired-get-filename does this unhide+hide:
    (when hidden
      (dired-unhide-subdir))
    (save-excursion
      (if (setq p1 (dired-move-to-filename (not no-error-if-not-filep)))
 (setq p2 (dired-move-to-end-of-filename no-error-if-not-filep))))
    (when hidden
      (dired-hide-subdir 1))


But dired-hide-subdir says it may move the point:
(defun dired-hide-subdir (arg)
  "Hide or unhide the current subdirectory and move to next directory. […]"
[…]
(goto-char (cdr elt))
[…]
)


With this it works:
    (when hidden
      (save-excursion (dired-hide-subdir 1)))

Patch:


diff --git a/lisp/dired.el b/lisp/dired.el
index ac12bf42565..019cf9d8fc4 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3297,7 +3297,7 @@ dired-get-filename
       (if (setq p1 (dired-move-to-filename (not no-error-if-not-filep)))
          (setq p2 (dired-move-to-end-of-filename no-error-if-not-filep))))
     (when hidden
-      (dired-hide-subdir 1))
+      (save-excursion (dired-hide-subdir 1)))
     ;; nil if no file on this line, but no-error-if-not-filep is t:
     (if (setq file (and p1 p2 (buffer-substring p1 p2)))
        (progn








In GNU Emacs 32.0.50 (build 7, x86_64-pc-linux-gnu) of 2026-08-12 built on sonn
Repository revision: c693e12efa3fecc72cbc5a53047d5a360854ded2
Repository branch: master
System Description: Devuan GNU/Linux 6 (excalibur)

Configured using:
 'configure --prefix=/opt/dc/emacs/ --without-lcms2
--without-libsystemd --without-dbus
 --without-sound --with-mailutils --with-native-compilation=yes
--without-modules
 --with-x-toolkit=no --without-xim --without-imagemagick --without-xft
--without-harfbuzz
 --without-libotf --without-xwidgets --without-xpm --with-tiff=no
--without-tiff --without-jpeg
 --without-gif --without-png --without-webp --without-rsvg
--without-cairo --without-x
 --enable-checking=yes,glyphs 'CFLAGS=-g3 -O2''

Configured features:
GMP GNUTLS LIBXML2 NATIVE_COMP NOTIFY INOTIFY PDUMPER SECCOMP SQLITE3
THREADS XIM ZLIB

Important settings:
  value of $LANG: en_US.UTF-8

  value of $XMODIFIERS: @im=SCIM
  locale-coding-system: utf-8-unix
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.