Questions tagged [font-lock]

Font Lock mode is a minor mode, always local to a particular buffer, which assigns faces to the text in the buffer.

Font Lock mode is a minor mode, always local to a particular buffer, which assigns faces to the text in the buffer.


Each buffer's major mode tells Font Lock mode which text to fontify; for instance, programming language modes fontify syntactically relevant constructs like comments, strings, and function names.

Font Lock mode is enabled by default. To toggle it in the current buffer, type M-xfont-lock-mode. A positive numeric argument unconditionally enables Font Lock mode, and a negative or zero argument disables it.

Type M-xglobal-font-lock-mode to toggle Font Lock mode in all buffers. To impose this setting for future Emacs sessions, customize the variable global-font-lock-mode (see Easy Customization), or add the following line to your init file:

(global-font-lock-mode 0)

306 questions
113
votes
9 answers

How can I get a ruler at column 80?

As a programmer, I want to see a ruler at a specific column (usually 80), both so I see when I cross that column, but also to see how close I am getting to it so I can reformat my code early. The options I have found so far are all not achieving…
Jorgen Schäfer
  • 3,899
  • 2
  • 17
  • 19
17
votes
2 answers

How can I use the SE flavor of Markdown in emacs?

I would like to use the SE flavor of markdown in my emacs. The default Markdown mode has some features (backticks and indentation mark code, # makes a header and > also changes the font) but I would also like to have: * to make a list item,…
terdon
  • 745
  • 6
  • 21
17
votes
1 answer

Optimizing font lock performance

I want to perform a variant of anchored font lock matching. I have function definitions that start with a list of names, and I want those names to be highlighted inside the function body. I have created a function that does this and registered it as…
Joakim Hårsman
  • 719
  • 5
  • 11
15
votes
1 answer

Make org-mode markup symbols invisible?

In Emacs, one can use asterisks * to achieve bold font, for example, *bold*. My question is can I make the asterisks invisible? i.e. bold instead of *bold*. Same question for strike through, italics, etc. I know this should be achievable. As an…
Alex
  • 415
  • 5
  • 12
15
votes
3 answers

Highlighting shell variables within quotes

In vim, the following document will cause the $PWD on lines 2 and 3 to be colored in two different ways: #/bin/sh echo "Current Directory: $PWD" echo 'Current Directory: $PWD' The first instance of $PWD will be in a different color from the rest of…
nispio
  • 8,175
  • 2
  • 35
  • 73
14
votes
1 answer

Apply ANSI color escape sequences for Org Babel results

Feature There is a nice built-in Emacs feature to colorize strings with ANSI color escape sequences. So evaluating the following Elisp code, will insert the "Test text" at the point with proper colors. (require 'ansi-color) (insert (ansi-color-apply…
atevm
  • 928
  • 7
  • 16
13
votes
3 answers

Fontify a region of a buffer with another major mode

I have a buffer that shows documentation for Ansible modules. This buffer has its own major mode which provides all the standard stuff. Notably, it fontifies the buffer to highlight inline markup, options, sections, etc. All in all, it is pretty…
user227
11
votes
1 answer

How do I specify a custom face with font-lock-defaults?

If I define font lock keywords using existing faces, I can highlight the string 'foo'. (defconst my-mode-font-lock-keywords (list (cons "foo" 'font-lock-type-face))) (define-derived-mode my-mode fundamental-mode "My mode" "A demo mode." …
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59
11
votes
1 answer

Color declared variables

I'm looking for a simple way to make emacs remember of declared variable in a single function in C/C++. By "simple", I mean without any external package, just with some elisp lines in configuration files. My default Emacs configuration colors…
Aracthor
  • 173
  • 7
10
votes
1 answer

How to customize syntax highlight for just a given mode

I would like to change the syntax highlighting in my lua-mode.el without affecting other major modes. Just as an example, I would like "key words" like if, then, else to be in bold and blue typeface when in lua-mode (instead of the default pink)…
Pier Paolo
  • 275
  • 3
  • 10
10
votes
2 answers

How to add complex syntax highlighting in a minor mode?

I'd like to highlight code with various faces in a minor mode. Here's a screenshot that's close to what I want: One thing that I'm missing is having the comment chars # in font-lock-comment-face. The idea is to have comments that "belong" to an…
abo-abo
  • 13,943
  • 1
  • 29
  • 43
10
votes
0 answers

How to investigate "color bleeding"?

I frequently have color-bleed issues in emacs, most often with AUCTeX: all of a sudden and for no apparent reason, the line I'm writing will be fontified as math. First things first: no, I do not have any lone $ character in a verbatim context.…
T. Verron
  • 4,233
  • 1
  • 22
  • 55
9
votes
2 answers

How to implement the piping operator %>% in ESS mode?

Recently, R witnessed the smart introduction of the piping operator %>% or then operator in code which I use quite frequently nowadays. I wonder if this has already been implemented in the newest version of ESS. If not, it shouldn't be a problem to…
doctorate
  • 1,789
  • 16
  • 39
9
votes
1 answer

Make consistent syntax highlighting of LaTeX source blocks

Org manual's solution for syntax highlighting of org-babel code blocks is to turn on native fontification with (setq org-src-fontify-natively t) works well for LaTeX code enclosed in blocks with #+BEGIN_SRC latex but not for blocks…
Emacs User
  • 5,553
  • 18
  • 48
8
votes
3 answers

How do I debug an "Invalid face reference: quote" message?

After using Emacs for some time, the message Invalid face reference: quote starts popping up in my message buffer. I'm not sure what causes it to start appearing. debug-on-message doesn't do anything (this is an error in the redisplay…
Clément
  • 3,924
  • 1
  • 22
  • 37
1
2 3
20 21