Questions tagged [font-lock]

Font-lock is a minor mode of GNU Emacs. It assigns faces locally to a particular buffer.

Font Lock mode is a minor mode of GNU Emacs. Font Lock mode is:

always local to a particular buffer, which assigns faces to (or fontifies) 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-x font-lock-mode. A positive numeric argument unconditionally enables Font Lock mode, and a negative or zero argument disables it.

[section 14.12 Gnu Emacs Manual]

111 questions
39
votes
5 answers

Set Emacs defaut font face per-buffer/mode

How do you change the default face which Emacs uses to style text on a per-mode basis? For example, say that I am already happy with the face customizations that I have, which include a default fixed-width font. However, in one particular mode…
emax
22
votes
1 answer

In Emacs, how do I display a message in the minibuffer with font face properties?

I want to display a colored string of text in the minibuffer, but when I use the 'message' function, the text-properties of are stripped.
Aemon Cannon
  • 440
  • 3
  • 8
15
votes
3 answers

emacs: is there a clear example of multi-line font-locking?

Some background, I'm comfortable with Emacs Lisp, and have written lots of lines of it. However I've never written a major mode, so I'm fairly new to how the font-locking mechanism works. For my current project, I'd like to add inlined javascript…
event_jr
  • 17,467
  • 4
  • 47
  • 62
9
votes
3 answers

Emacs: very slow scrolling with font-lock/syntax coloring

I'm trying to switch to Emacs from Vim for a few months and faced the strange problem: when font-lock is on, scrolling in emacs becomes very slow. Example of relevant part of config: (require 'vimpulse) (require 'font-lock) (require…
voidlizard
  • 805
  • 5
  • 10
8
votes
2 answers

Emacs: font-lock explanation

I'm using Emacs since a long time and I've customized it quite a lot. I've even written simple ELisp functions and now I'm starting to use macros more and more. I'm not anywhere near a knowledgable Emacs user but I'm not either a complete…
Cedric Martin
  • 5,945
  • 4
  • 34
  • 66
8
votes
3 answers

Updating font-lock keywords in emacs without major mode reload

I am doing small modification to SLIME, so that I can get all currently loaded symbols from Lisp, analyze them and make font-lock fontify them. I managed to do all these steps, but I have a small problem - when keyword list changes in font-lock the…
freiksenet
  • 3,569
  • 3
  • 28
  • 28
7
votes
1 answer

Highlighting TODOs in all programming modes

What is the root mode I need to hook to highlight TODOs in Ruby, Lisp, and C-like languages. I tried the following, but it doesn't highlight TODO in Ruby or Lisp: (defun highlight-todos (font-lock-add-keywords nil …
Natan Yellin
  • 6,063
  • 5
  • 38
  • 57
7
votes
1 answer

Is there a way to prevent font-locking from changing the font family (and change color only)?

Admittedly, this is something of a first world problem, but I'm sort of picky about the appearance of the display, and I find it really annoying when some mode sets a new font size, family, bold/italic, etc. What I'd like to do is put…
deong
  • 3,820
  • 21
  • 18
6
votes
1 answer

how to debug font lock keywords error

How can I debug font lock keywords I write? For example (progn (font-lock-add-keywords nil '( ;; ("hi1" . 'success) ("hi2" . (intern (concat "warn" "ing"))) )) (font-lock-fontify-buffer)) will produce the following message…
Jisang Yoo
  • 3,670
  • 20
  • 31
6
votes
2 answers

How to highlight all the function's name in Emacs' lisp-mode?

How to highlight all the function's name in Emacs' lisp-mode? I want them bolded. In other words, all the words from ( to the first space. Don't care exceptions like (a . b) Just like GitHub:
kuanyui
  • 782
  • 13
  • 23
5
votes
2 answers

How can I change the face of scalar variables in emacs cperl-mode?

In cperl-mode I am able to change the array and hash faces with M-x customize-group RET cperl-faces RET, and change Cperl Hash Face and Cperl Hash Face. But I can not see any option for changing the scalar variables color. I have tried to change…
Pablo Marin-Garcia
  • 4,151
  • 2
  • 32
  • 50
5
votes
2 answers

Emacs-lisp: prettify-symbols-mode for LaTeX

I was trying to port over the "pretty entities" behaviour from org-mode to latex-mode using the Emacs builtin prettify-symbols-mode. This mode uses font-lock-mode to display character sequences in a buffer as a single (unicode) character. By default…
kdb
  • 4,098
  • 26
  • 49
5
votes
2 answers

Why is font-lock-keyword-face highlighting text within double quotes in Emacs?

I am trying to set up a major mode in Emacs where I would like to highlight certain keywords. Using a template from this page: http://ergoemacs.org/emacs/elisp_syntax_coloring.html I tried: (setq testing-font-lock-keywords …
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
5
votes
2 answers

Apply font lock to quoted symbols in elisp

In Emacs I would like quoted symbols in emacs lisp such as: 'blah and display them in a different color. How can I use font-lock mode to do this?
Zameer Manji
  • 3,017
  • 5
  • 31
  • 42
5
votes
1 answer

Emacs syntax highlighting of nested regular expressions

I'm trying to write an Emacs major mode for working with biological sequence data (i.e. DNA and peptides), and I want to implement syntax highlighting where different letters are colored differently. Since the mode needs to be able to differentiate…
Mike B
  • 153
  • 2
  • 6
1
2 3 4 5 6 7 8