Subject: bug#74447: closed (Re: bug#74447: 30.0.92; asm-comment-char cannot be set via dir-local variables)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 02 Dec 2024 00:05:02 +0000

Your bug report

#74447: 30.0.92; asm-comment-char cannot be set via dir-local variables

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74447: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74447
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74447: 30.0.92; asm-comment-char cannot be set via dir-local variables
From: Stefan Monnier <[email-masked]>
To: Johann Klähn <[email-masked]>
Cc: Eli Zaretskii <[email-masked]>, [email-masked]
Date: Sun, 01 Dec 2024 19:04:50 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

> Thanks for the ping, Eli.  After fixing up the parens added by mistake
> in the second part of the patch it works great.  Thanks, Stefan!

Great, thank you, pushed to `master`.

>>>    (setq-local comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
>>> -  (setq-local comment-end ""))
>>> +  (setq-local comment-end "")
>>> +  ))
>
> ⬑ I reverted this part.

Rightly so!
Closing,

        Stefan

Subject: 30.0.92; asm-comment-char cannot be set via dir-local variables
From: Johann Klähn <[email-masked]>
To: [email-masked]
Date: Wed, 20 Nov 2024 20:12:16 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

In `.dir-locals.el' setting `((asm-mode . ((asm-comment-char . 35))))'
does not have the desired effect.  The comment char is still `;' instead
of `#'.  The reason is that when the syntax table is adjusted according
to the comment char in the body of `asm-mode', the dir-local variables
haven't been loaded yet: `run-mode-hooks' (which would call
`hack-local-variables') is only invoked _after_ the `define-derived-mode'
body, i.e., too late.

I'm using the following workaround:

    (defun asm-mode-set-comment-char-from-dir-local-variables ()
      "Load `asm-comment-char' from dir-local variables.
    This is a HACK, since in `asm-mode', `run-mode-hooks' (which would call
    `hack-local-variables') is only invoked after the `define-derived-mode' body,
    i.e., too late."
      (let ((enable-local-variables :safe))
        (hack-dir-local-variables)
        (when-let* ((char (alist-get 'asm-comment-char dir-local-variables-alist)))
          (setq-local asm-comment-char char))))
    (add-hook 'asm-mode-set-comment-hook #'asm-mode-set-comment-char-from-dir-local-variables)

But maybe there is a more principled approach?

In GNU Emacs 30.0.92 (build 5, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.0) of 2024-11-19 built on toolbx
Repository revision: 331610aef0572eacb2846f817e979aa5e29170b7
Repository branch: emacs-30
System Description: Fedora Linux 41 (Workstation Edition)

Configured using:
 'configure --with-dbus --with-gif --with-jpeg --with-png --with-rsvg
 --with-tiff --with-xpm --with-gpm=no --with-modules --with-harfbuzz
 --with-cairo --with-native-compilation --enable-link-time-optimization
 --with-pgtk 'CFLAGS=-DMAIL_USE_LOCKF -O2 -fexceptions -g
 -grecord-gcc-switches -pipe -Wp,-D_FORTIFY_SOURCE=2
 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-z,relro'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: en_AU.UTF-8
  value of $LC_NUMERIC: en_AU.UTF-8
  value of $LC_TIME: en_AU.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Assembler