This page is about library '''<tt>[[hi-var.el]]</tt>''', which provides highlighting of occurrences of variables in an EmacsLisp buffer, using [[minor mode]] '''`hi-var-mode''''.

Variables of these types can be highlighted:

* User [[option]]s
* Other dynamically scoped variables
* File-local variables
* Other buffer-local variables

Note: Library ##hi-var.el## supersedes library <tt>[[dyna-show.el]]</tt> (see HighlightDynamicVariables), which
highlights dynamic variables but doesn't highlight file-local
and buffer-local variables.

Variables of these types are highlighted using faces '''`hivar-options'''', '''`hivar-dynamic-vars'''', '''`hivar-file-local-vars'''', and '''`hivar-buffer-local-vars'''', respectively.

`hi-var-mode' merges face `hivar-options' or `hivar-dynamic-vars' with
face `hivar-file-local-vars' or `hivar-buffer-local-vars', so you can
tell when a dynamic variable is buffer- or file-local.  By default, the former pair of faces use an underline and the latter use an overline.

If you don't want to highlight all of these types of variables,
you can use [[option]] '''`hivar-highlighting'''' to choose the types you
do want to highlight.

The simple built-in test `special-variable-p' is used, to tell
whether a variable is dynamically bound.  That test is not 100%
reliable.  It doesn't respect vacuous `defvar' sexps, which
declare a variable to be special in a given context, without
assigning a value to the variable.  Instead, it uses `defvar',
`defconst', and `defcustom' sexps with a value arg present.

See also the related library '''<tt>[[hl-defined.el]]</tt>''', which highlights
defined or undefined Emacs-Lisp symbols (functions, variables, or
both).  You can use these two libraries together - command
'''`hdefd-highlight-mode'''' to highlight functions and/or variables,
and command `hi-var-mode' to highlight dynamic variables. When used together, the variable highlighting of ##hi-var.el## overrides that of ##hl-defined.el##.

[[image:HighlightVariables]]

Put this in your init file, after adding ##hi-var.el## to your `load-path':

   (require 'hi-var)

If you want to turn on this highlighting automatically whenever
you enter EmacsLisp mode then you can do this in your InitFile:

  (require 'hi-var)
  (add-hook 'emacs-lisp-mode-hook 'hi-var-mode 'APPEND)


----

CategoryHelp CategoryEditing CategoryDisplay CategoryLisp CategoryFaces CategoryCode

