1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Handle elisp #-syntax better in Emacs Lisp mode

* elisp-mode.el (elisp-mode-syntax-propertize): New function.
(emacs-lisp-mode): Set it as syntax-propertize-function (bug#15998).
This commit is contained in:
Noam Postavsky 2022-05-06 18:31:00 +02:00 committed by Lars Ingebrigtsen
parent 7deaa2e36b
commit 6ccc4b6bc8

View file

@ -237,6 +237,20 @@ Comments in the form will be lost."
(if (bolp) (delete-char -1))
(indent-region start (point)))))
(defun elisp-mode-syntax-propertize (start end)
(goto-char start)
(funcall
(syntax-propertize-rules
;; Empty symbol.
("##" (0 (unless (nth 8 (syntax-ppss))
(string-to-syntax "_"))))
((rx "#" (or (seq (group-n 1 "&" (+ digit)) ?\") ; Bool-vector.
(seq (group-n 1 "s") "(") ; Record.
(seq (group-n 1 (+ "^")) "["))) ; Char-table.
(1 (unless (save-excursion (nth 8 (syntax-ppss (match-beginning 0))))
(string-to-syntax "'")))))
start end))
(defcustom emacs-lisp-mode-hook nil
"Hook run when entering Emacs Lisp mode."
:options '(eldoc-mode imenu-add-menubar-index checkdoc-minor-mode)
@ -310,6 +324,7 @@ be used instead.
#'elisp-eldoc-var-docstring nil t)
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
(setq-local project-vc-external-roots-function #'elisp-load-path-roots)
(setq-local syntax-propertize-function #'elisp-mode-syntax-propertize)
(add-hook 'completion-at-point-functions
#'elisp-completion-at-point nil 'local)
(add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)