summaryrefslogtreecommitdiff
path: root/devdocs/elisp/precalculated-fontification.html
blob: 65013d55cf27b21637ef99f8787573e3df3ce430 (plain)
1
2
3
4
5
6
 <h4 class="subsection">Precalculated Fontification</h4> <p>Some major modes such as <code>list-buffers</code> and <code>occur</code> construct the buffer text programmatically. The easiest way for them to support Font Lock mode is to specify the faces of text when they insert the text in the buffer. </p> <p>The way to do this is to specify the faces in the text with the special text property <code>font-lock-face</code> (see <a href="special-properties">Special Properties</a>). When Font Lock mode is enabled, this property controls the display, just like the <code>face</code> property. When Font Lock mode is disabled, <code>font-lock-face</code> has no effect on the display. </p> <p>It is ok for a mode to use <code>font-lock-face</code> for some text and also use the normal Font Lock machinery. But if the mode does not use the normal Font Lock machinery, it should not set the variable <code>font-lock-defaults</code>. In this case the <code>face</code> property will not be overridden, so using the <code>face</code> property could work too. However, using <code>font-lock-face</code> is generally preferable as it allows the user to control the fontification by toggling <code>font-lock-mode</code>, and lets the code work regardless of whether the mode uses Font Lock machinery or not. </p><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/Precalculated-Fontification.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Precalculated-Fontification.html</a>
  </p>
</div>