For:
(defun my-ag/font-lock-extend-region ()
(save-excursion
(goto-char font-lock-beg)
(forward-line 2)
(setq font-lock-beg (point))))
I've got:
Warning: reference to free variable 'font-lock-beg'
Warning: assignment to free variable 'font-lock-beg'
Documentation says:
font-lock-extend-region-functions is a variable defined in ‘font-lock.el’.
Each function is called with no argument; it is expected to adjust the
dynamically bound variables ‘font-lock-beg’ and ‘font-lock-end’; and return
non-nil if it did make such an adjustment.
Usual solution (defvar ...)
make this variables globally visible and may hide bugs.
How should I mask "reference/assignment to free variable" warning during compilation if variable is dynamically bounded?
defvar
ed infont-lock.el
, so it is safe for you to do so too. – sds Mar 29 '17 at 21:56(defvar ...)
[...] may hide bugs" - what kind of bugs are you thinking of? – npostavs Mar 29 '17 at 22:48font-lock.el
. If you loadfont-lock.el[c]
before byte-compiling then you will see no such warning. Put(require 'font-lock)
in your file that you're byte-compiling, and the warnings should go away. – Drew Mar 30 '17 at 0:46