summaryrefslogtreecommitdiff
path: root/devdocs/elisp/other-font-lock-variables.html
blob: b19c883e33d46bd193bc7f6ef06b986d17e30b05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 <h4 class="subsection">Other Font Lock Variables</h4> <p>This section describes additional variables that a major mode can set by means of <var>other-vars</var> in <code>font-lock-defaults</code> (see <a href="font-lock-basics">Font Lock Basics</a>). </p> <dl> <dt id="font-lock-mark-block-function">Variable: <strong>font-lock-mark-block-function</strong>
</dt> <dd>
<p>If this variable is non-<code>nil</code>, it should be a function that is called with no arguments, to choose an enclosing range of text for refontification for the command <kbd>M-x font-lock-fontify-block</kbd>. </p> <p>The function should report its choice by placing the region around it. A good choice is a range of text large enough to give proper results, but not too large so that refontification becomes slow. Typical values are <code>mark-defun</code> for programming modes or <code>mark-paragraph</code> for textual modes. </p>
</dd>
</dl> <dl> <dt id="font-lock-extra-managed-props">Variable: <strong>font-lock-extra-managed-props</strong>
</dt> <dd><p>This variable specifies additional properties (other than <code>font-lock-face</code>) that are being managed by Font Lock mode. It is used by <code>font-lock-default-unfontify-region</code>, which normally only manages the <code>font-lock-face</code> property. If you want Font Lock to manage other properties as well, you must specify them in a <var>facespec</var> in <code>font-lock-keywords</code> as well as add them to this list. See <a href="search_002dbased-fontification">Search-based Fontification</a>. </p></dd>
</dl> <dl> <dt id="font-lock-fontify-buffer-function">Variable: <strong>font-lock-fontify-buffer-function</strong>
</dt> <dd><p>Function to use for fontifying the buffer. The default value is <code>font-lock-default-fontify-buffer</code>. </p></dd>
</dl> <dl> <dt id="font-lock-unfontify-buffer-function">Variable: <strong>font-lock-unfontify-buffer-function</strong>
</dt> <dd><p>Function to use for unfontifying the buffer. This is used when turning off Font Lock mode. The default value is <code>font-lock-default-unfontify-buffer</code>. </p></dd>
</dl> <dl> <dt id="font-lock-fontify-region-function">Variable: <strong>font-lock-fontify-region-function</strong>
</dt> <dd><p>Function to use for fontifying a region. It should take two arguments, the beginning and end of the region, and an optional third argument <var>verbose</var>. If <var>verbose</var> is non-<code>nil</code>, the function should print status messages. The default value is <code>font-lock-default-fontify-region</code>. </p></dd>
</dl> <dl> <dt id="font-lock-unfontify-region-function">Variable: <strong>font-lock-unfontify-region-function</strong>
</dt> <dd><p>Function to use for unfontifying a region. It should take two arguments, the beginning and end of the region. The default value is <code>font-lock-default-unfontify-region</code>. </p></dd>
</dl> <dl> <dt id="font-lock-flush-function">Variable: <strong>font-lock-flush-function</strong>
</dt> <dd><p>Function to use for declaring that a region’s fontification is out of date. It takes two arguments, the beginning and end of the region. The default value of this variable is <code>font-lock-after-change-function</code>. </p></dd>
</dl> <dl> <dt id="font-lock-ensure-function">Variable: <strong>font-lock-ensure-function</strong>
</dt> <dd><p>Function to use for making sure a region of the current buffer has been fontified. It is called with two arguments, the beginning and end of the region. The default value of this variable is a function that calls <code>font-lock-default-fontify-buffer</code> if the buffer is not fontified; the effect is to make sure the entire accessible portion of the buffer is fontified. </p></dd>
</dl> <dl> <dt id="jit-lock-register">Function: <strong>jit-lock-register</strong> <em>function &amp;optional contextual</em>
</dt> <dd>
<p>This function tells Font Lock mode to run the Lisp function <var>function</var> any time it has to fontify or refontify part of the current buffer. It calls <var>function</var> before calling the default fontification functions, and gives it two arguments, <var>start</var> and <var>end</var>, which specify the region to be fontified or refontified. If <var>function</var> performs fontifications, it can return a list of the form <code><span class="nolinebreak">(jit-lock-bounds</span> <var>beg</var> . <var>end</var>)</code>, to indicate the bounds of the region it actually fontified; Just-In-Time (a.k.a. <acronym>“JIT”</acronym>) font-lock will use this information to optimize subsequent redisplay cycles and regions of buffer text it will pass to future calls to <var>function</var>. </p> <p>The optional argument <var>contextual</var>, if non-<code>nil</code>, forces Font Lock mode to always refontify a syntactically relevant part of the buffer, and not just the modified lines. This argument can usually be omitted. </p> <p>When Font Lock is activated in a buffer, it calls this function with a non-<code>nil</code> value of <var>contextual</var> if the value of <code>font-lock-keywords-only</code> (see <a href="syntactic-font-lock">Syntactic Font Lock</a>) is <code>nil</code>. </p>
</dd>
</dl> <dl> <dt id="jit-lock-unregister">Function: <strong>jit-lock-unregister</strong> <em>function</em>
</dt> <dd><p>If <var>function</var> was previously registered as a fontification function using <code>jit-lock-register</code>, this function unregisters it. </p></dd>
</dl>   <dl> <dt id="jit-lock-debug-mode">Command: <strong>jit-lock-debug-mode</strong> <em>&amp;optional arg</em>
</dt> <dd><p>This is a minor mode whose purpose is to help in debugging code that is run by JIT font-lock. When this mode is enabled, most of the code that JIT font-lock normally runs during redisplay cycles, where Lisp errors are suppressed, is instead run by a timer. Thus, this mode allows using debugging aids such as <code>debug-on-error</code> (see <a href="error-debugging">Error Debugging</a>) and Edebug (see <a href="edebug">Edebug</a>) for finding and fixing problems in font-lock code and any other code run by JIT font-lock. </p></dd>
</dl><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Other-Font-Lock-Variables.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Other-Font-Lock-Variables.html</a>
  </p>
</div>