syrup/superfluous-parentheses.el

26 lines
1.1 KiB
EmacsLisp
Raw Permalink Normal View History

2024-05-29 14:28:38 +00:00
;;; 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