>> 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? IIRC there are 2 "standard" solutions: - in `asm-mode` use (add-hook 'hack-local-variables-hook #'asm--set-comment-syntax nil t) where `asm--set-comment-syntax` would be a new function that sets the syntax-table according to `asm-comment-char`. - in `asm-mode` move the syntax-table setting code to an `:after-hook` section, as in the patch below. Stefan