elisp - Highlight non-local variables in Emacs Lisp -
in js2-mode, global variables automatically highlighted me:

how can same in emacs lisp? i'd able highlight flymake-log-level , barr in following:
(defun foo () (let (bar baz) (setq baz flymake-log-level) ;; flymake-log-level isn't locally bound (setq barr (1+ flymake-log-level)))) ;; misspelled bar
it's possible take advantage of byte-compiler installing flycheck. flycheck alternative flymake , has support elisp.
it won't first example, second (assuming necessary require present):
(require 'flymake) (defun foo () (let (bar baz) (setq baz flymake-log-level) ;; no complaints here (setq barr (1+ flymake-log-level)))) ;; assignment free variable `barr' there's hl-defined.el, minor mode described in question. install it, run hdefd-highlight-mode in emacs-lisp-mode buffer. can run command hdefd-cycle until showing variables aren't defined. gives like:

(this isn't perfect, hl-defined doesn't recognise fn parameter not free variable, , confuses function list parameter used here. still, it's helpful use case described in question.)
finally, packages include highlighting functions define. example, dash.el provides highlighting functions, plus variable names uses in anaphoric macros (i.e highlights it).
;; enable syntax highlighting of dash functions (eval-after-load "dash" '(dash-enable-font-lock))
Comments
Post a Comment