GNU bug report logs - #74447
30.0.92; asm-comment-char cannot be set via dir-local variables

Previous Next

Package: emacs;

Reported by: Johann Klähn <johann <at> jklaehn.de>

Date: Wed, 20 Nov 2024 19:13:02 UTC

Severity: normal

Found in version 30.0.92

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 74447 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Johann Klähn <johann <at> jklaehn.de>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 74447 <at> debbugs.gnu.org
Subject: Re: bug#74447: 30.0.92;
 asm-comment-char cannot be set via dir-local variables
Date: Wed, 20 Nov 2024 21:21:28 +0200
> From: Johann Klähn <johann <at> jklaehn.de>
> Date: Wed, 20 Nov 2024 20:12:16 +0100
> 
> 
> 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?

Stefan, any suggestions?




This bug report was last modified 264 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.