Refactor :lang emacs-lisp

This commit is contained in:
Henrik Lissner 2020-05-25 02:29:30 -04:00
parent 7ca20f158b
commit ada4110730
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 79 additions and 71 deletions

View file

@ -47,40 +47,39 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
;; Fixed indenter that intends plists sensibly.
lisp-indent-function #'+emacs-lisp-indent-function)
;; variable-width indentation is superior in elisp
(add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode nil #'eq)
;; variable-width indentation is superior in elisp. Otherwise, `dtrt-indent'
;; and `editorconfig' would force fixed indentation on elisp.
(add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode)
(add-hook! 'emacs-lisp-mode-hook
;; Allow folding of outlines in comments
#'outline-minor-mode
;; fontificiation
;; Make parenthesis depth easier to distinguish at a glance
#'rainbow-delimiters-mode
;; Make quoted symbols easier to distinguish from free variables
#'highlight-quoted-mode
;; initialization
#'+emacs-lisp-extend-imenu-h)
(autoload 'straight-register-file-modification "straight")
(add-hook! 'emacs-lisp-mode-hook
(defun +emacs-lisp-init-straight-h ()
(when (file-in-directory-p (or buffer-file-name default-directory) doom-local-dir)
(add-hook 'after-save-hook #'straight-register-file-modification
nil 'local))))
;; Extend imenu support to Doom constructs
#'+emacs-lisp-extend-imenu-h
;; Ensure straight sees modifications to installed packages
#'+emacs-lisp-init-straight-maybe-h)
;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in
;; emacs configs, so we disable `emacs-lisp-checkdoc' and reduce the
;; `emacs-lisp' checker's verbosity.
(add-hook 'flycheck-mode-hook #'+emacs-lisp-reduce-flycheck-errors-in-emacs-config-h)
;; Special syntax highlighting for elisp...
;; Enhance elisp syntax highlighting, by highlighting Doom-specific
;; constructs, defined symbols, and truncating :pin's in `package!' calls.
(font-lock-add-keywords
'emacs-lisp-mode
(append `(;; custom Doom cookies
("^;;;###\\(autodef\\|if\\|package\\)[ \n]" (1 font-lock-warning-face t)))
;; Shorten the :pin of `package!' statements to 10 characters
`(("(package!\\_>" (0 (+emacs-lisp-truncate-pin))))
;; highlight defined, special variables & functions
(when +emacs-lisp-enable-extra-fontification
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))
`(("(package!\\_>" (0 (+emacs-lisp-truncate-pin))))))
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))
;; Recenter window after following definition
(advice-add #'elisp-def :after #'doom-recenter-a)
@ -90,17 +89,13 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
(when-let (ret (funcall orig-fn sym))
(concat ret " "
(let* ((truncated " [...]")
(limit (- (frame-width) (length ret) (length truncated) 1))
(print-escape-newlines t)
(str (symbol-value sym))
(str (prin1-to-string
(if (stringp str)
(replace-regexp-in-string "\n" " " str)
str)))
(str-length (length str))
(short (< str-length limit)))
(concat (substring (propertize str 'face 'warning)
0 (if short str-length limit))
(unless short truncated))))))
(str (prin1-to-string str))
(limit (- (frame-width) (length ret) (length truncated) 1)))
(format (format "%%0.%ds%%s" limit)
(propertize str 'face 'warning)
(if (< (length str) limit) "" truncated))))))
(map! :localleader
:map emacs-lisp-mode-map
@ -145,6 +140,7 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
;;;###package overseer
(autoload 'overseer-test "overseer" nil t)
;; Properly lazy load overseer by not loading it so early:
(remove-hook 'emacs-lisp-mode-hook #'overseer-enable-mode)