Fix #5187: syntax highlighting in ielm REPL
This commit is contained in:
parent
3aeb0c060f
commit
243cb43fec
1 changed files with 24 additions and 20 deletions
|
@ -153,24 +153,28 @@ employed so that flycheck still does *some* helpful linting.")
|
||||||
:config
|
:config
|
||||||
(set-lookup-handlers! 'inferior-emacs-lisp-mode
|
(set-lookup-handlers! 'inferior-emacs-lisp-mode
|
||||||
:definition #'+emacs-lisp-lookup-definition
|
:definition #'+emacs-lisp-lookup-definition
|
||||||
:documentation #'+emacs-lisp-lookup-documentation))
|
:documentation #'+emacs-lisp-lookup-documentation)
|
||||||
|
|
||||||
;; Adapted from http://www.modernemacs.com/post/comint-highlighting/ to add
|
;; Adapted from http://www.modernemacs.com/post/comint-highlighting/ to add
|
||||||
;; syntax highlighting to ielm REPLs.
|
;; syntax highlighting to ielm REPLs.
|
||||||
(add-hook! 'ielm-mode-hook
|
(setq ielm-font-lock-keywords
|
||||||
(defun +emacs-lisp-init-syntax-highlighting-h ()
|
(append '(("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)"
|
||||||
(font-lock-add-keywords
|
(1 font-lock-comment-face)
|
||||||
nil (cl-loop for (matcher . match-highlights)
|
(2 font-lock-constant-face)))
|
||||||
in (append lisp-el-font-lock-keywords-2 lisp-cl-font-lock-keywords-2)
|
(when (require 'highlight-numbers nil t)
|
||||||
|
(highlight-numbers--get-regexp-for-mode 'emacs-lisp-mode))
|
||||||
|
(cl-loop for (matcher . match-highlights)
|
||||||
|
in (append lisp-el-font-lock-keywords-2
|
||||||
|
lisp-cl-font-lock-keywords-2)
|
||||||
collect
|
collect
|
||||||
`((lambda (limit)
|
`((lambda (limit)
|
||||||
(and ,(if (symbolp matcher)
|
(when ,(if (symbolp matcher)
|
||||||
`(,matcher limit)
|
`(,matcher limit)
|
||||||
`(re-search-forward ,matcher limit t))
|
`(re-search-forward ,matcher limit t))
|
||||||
;; Only highlight matches after the prompt
|
;; Only highlight matches after the prompt
|
||||||
(> (match-beginning 0) (car comint-last-prompt))
|
(> (match-beginning 0) (car comint-last-prompt))
|
||||||
;; Make sure we're not in a comment or string
|
;; Make sure we're not in a comment or string
|
||||||
(let ((state (sp--syntax-ppss)))
|
(let ((state (syntax-ppss)))
|
||||||
(not (or (nth 3 state)
|
(not (or (nth 3 state)
|
||||||
(nth 4 state))))))
|
(nth 4 state))))))
|
||||||
,@match-highlights)))))
|
,@match-highlights)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue