Subject: 29.0.60; Dired: invalid face reference with dir symlinks

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sat, 21 Jan 2023 00:02:39 +0000

Tags: patch

0. emacs -Q
1. C-h e
2. (let* ((parent (make-temp-file "my-" t))
          (child  (expand-file-name "child" parent))
          (link   (expand-file-name "link" parent)))
     (make-directory child)
     (make-symbolic-link child link)
     (dired parent))
   C-x C-e

Expected:
- Link target fontified with 'dired-directory' face
Result:
- Link target fontified with undefined 'dired-directory-face' face
- *Messages* says 'Invalid face reference: dired-directory-face'

This seems to be a regression in Emacs 29 (https://bugs.gnu.org/57293):

Use a list of text properties to search in symlink filenames in Wdired
0ab49d46ddb 2022-08-27 22:43:40 +0300
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=0ab49d46ddb

Something like this would fix the problem:

diff --git a/lisp/dired.el b/lisp/dired.el
index 42d15f27a54..2bcb28a0e00 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -789,7 +789,7 @@ dired-font-lock-keywords
                '(dired-move-to-filename)
                nil
                '(1 dired-symlink-face)
-               '(2 '(face dired-directory-face dired-symlink-filename t))))
+               '(2 `(face ,dired-directory-face dired-symlink-filename t))))
    ;;
    ;; Symbolic link to a non-directory.
    (list dired-re-sym

But I don't know whether it's acceptable for emacs-29, or whether it
conses too much during font lock.  In the latter case, we could evaluate
dired-directory-face once (when dired-font-lock-keywords is defined), or
we could use the 'dired-directory' face directly.  WDYT?

Thanks,

-- 
Basil

In GNU Emacs 29.0.60 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.16.0, Xaw3d scroll bars) of 2023-01-20 built on tia
Repository revision: d63e1a89518338bc3450b11d6c2d4644cb0440e1
Repository branch: wt/emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12101006
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure 'CFLAGS=-O0 -ggdb3' --prefix=/home/blc/.local
 --program-suffix=-29 --enable-checking=yes,glyphs
 --enable-check-lisp-object-type --with-file-notification=yes
 --with-native-compilation --with-x-toolkit=lucid --with-x'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XAW3D XDBE XIM
XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LANG: en_IE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822
mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils dired-aux cl-loaddefs comp
comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode
bytecomp byte-compile cl-lib dired dired-loaddefs rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
xinput2 x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 83436 6516)
 (symbols 48 7258 0)
 (strings 32 24732 1773)
 (string-bytes 1 750425)
 (vectors 16 18404)
 (vector-slots 8 343752 13751)
 (floats 8 42 33)
 (intervals 56 297 0)
 (buffers 984 12))