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?
defvared infont-lock.el, so it is safe for you to do so too.(defvar ...)[...] may hide bugs" - what kind of bugs are you thinking of?font-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.