elisp - Highlight non-local variables in Emacs Lisp -


in js2-mode, global variables automatically highlighted me:

enter image description here

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:

hl-defined screenshot

(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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -