Emacs support

This commit is contained in:
~keith 2022-05-12 17:20:50 +00:00
parent cbf4c267df
commit d8be7aaeb2

View file

@ -0,0 +1,25 @@
;;; superfluous-parentheses --- Emacs support for [] and {} in lisp-mode
;;; Code:
(defun superfluous-modify-font-lock-keywords (rule-table)
(dolist (rule rule-table)
(when (and (consp rule) (stringp (car rule)))
(when (string-prefix-p "(" (car rule))
(rplaca rule (concat "\\s(" (substring (car rule) 1)))))))
(add-hook! lisp-mode
(modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table)
(modify-syntax-entry ?\] ")[" lisp-mode-syntax-table)
(modify-syntax-entry ?\{ "(}" lisp-mode-syntax-table)
(modify-syntax-entry ?\} "){" lisp-mode-syntax-table)
(superfluous-modify-font-lock-keywords lisp-cl-font-lock-keywords-1)
(superfluous-modify-font-lock-keywords lisp-cl-font-lock-keywords-2)
(superfluous-modify-font-lock-keywords lisp-cl-font-lock-keywords))
;;; Commentary:
;; This package modifies the lisp-mode syntax table and font-lock keywords to
;; provide proper support for using square brackets and curly braces in Common
;; Lisp code, as per superfluous-parentheses.
(provide 'superfluous-parentheses)
;;; superfluous-parentheses.el ends here