Add syntax highlighting to ielm buffers
Taken from http://www.modernemacs.com/post/comint-highlighting/ Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
b343f238fa
commit
a616e1f6ba
1 changed files with 34 additions and 0 deletions
|
@ -90,6 +90,40 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||||
"f" #'find-function
|
"f" #'find-function
|
||||||
"v" #'find-variable)))
|
"v" #'find-variable)))
|
||||||
|
|
||||||
|
(use-package! ielm
|
||||||
|
:config
|
||||||
|
;; Adapted from http://www.modernemacs.com/post/comint-highlighting/
|
||||||
|
(require 'dash)
|
||||||
|
|
||||||
|
(defun doom--kwd->comint-kwd (kwd)
|
||||||
|
"Converts a `font-lock-keywords' KWD for `comint-mode' input fontification."
|
||||||
|
(-let (((matcher . match-highlights) kwd))
|
||||||
|
;; below is ` quoted but breaks my blogs syntax higlighting, so removing it!
|
||||||
|
;; make sure to capture first paren in a ` if copying!
|
||||||
|
`((lambda (limit)
|
||||||
|
;; Matcher can be a function or a regex
|
||||||
|
(when ,(if (symbolp matcher)
|
||||||
|
`(,matcher limit)
|
||||||
|
`(re-search-forward ,matcher limit t))
|
||||||
|
;; While the SUBEXP can be anything, this search always can use zero
|
||||||
|
(-let ((start (match-beginning 0))
|
||||||
|
((comint-last-start . comint-last-end) comint-last-prompt)
|
||||||
|
(state (syntax-ppss)))
|
||||||
|
(and (> start comint-last-start)
|
||||||
|
;; Make sure not in comment or string
|
||||||
|
;; have to manually do this in custom MATCHERs
|
||||||
|
(not (or (nth 3 state) (nth 4 state)))))))
|
||||||
|
,@match-highlights)))
|
||||||
|
|
||||||
|
(setq doom--ielm-font-lock-kwds
|
||||||
|
`(,@(-map #'doom--kwd->comint-kwd lisp-el-font-lock-keywords-2)
|
||||||
|
,@(-map #'doom--kwd->comint-kwd lisp-cl-font-lock-keywords-2)))
|
||||||
|
|
||||||
|
(add-hook! 'ielm-mode-hook
|
||||||
|
(defun doom--set-ielm-kwds-h ()
|
||||||
|
(interactive)
|
||||||
|
(message "running my hook boy")
|
||||||
|
(setq-local font-lock-keywords doom--ielm-font-lock-kwds))))
|
||||||
;;
|
;;
|
||||||
;;; Packages
|
;;; Packages
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue