Merge pull request #1892 from rgrinberg/syntax-highlight-ielm
lang/emacs-lisp: add syntax highlighting to ielm buffers
This commit is contained in:
commit
c8b3e7f5ea
1 changed files with 20 additions and 0 deletions
|
@ -90,6 +90,26 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||||
"f" #'find-function
|
"f" #'find-function
|
||||||
"v" #'find-variable)))
|
"v" #'find-variable)))
|
||||||
|
|
||||||
|
;; Adapted from http://www.modernemacs.com/post/comint-highlighting/
|
||||||
|
(add-hook! 'ielm-mode-hook
|
||||||
|
(defun +emacs-lisp-init-syntax-highlighting-h ()
|
||||||
|
(font-lock-add-keywords
|
||||||
|
nil (cl-loop for (matcher . match-highlights)
|
||||||
|
in (append lisp-el-font-lock-keywords-2 lisp-cl-font-lock-keywords-2)
|
||||||
|
collect
|
||||||
|
`((lambda (limit)
|
||||||
|
(and ,(if (symbolp matcher)
|
||||||
|
`(,matcher limit)
|
||||||
|
`(re-search-forward ,matcher limit t))
|
||||||
|
;; Only highlight matches after the prompt
|
||||||
|
(> (match-beginning 0) (car comint-last-prompt))
|
||||||
|
;; Make sure we're not in a comment or string
|
||||||
|
(let ((state (sp--syntax-ppss)))
|
||||||
|
(not (or (nth 3 state)
|
||||||
|
(nth 4 state))))))
|
||||||
|
,@match-highlights))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Packages
|
;;; Packages
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue