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
4
votes
1 answer

Avoid font-locking interfering inside of comments

In my font-lock-defaults I have: ("\\(^\\| \\|\t\\)\\(![^\n]+\\)\n" 2 'factor-font-lock-comment) The comment character is ! and this makes it so comments get the right face. This works mostly, except when there is a competing font-locked entity…
Björn Lindqvist
  • 19,221
  • 20
  • 87
  • 122
4
votes
1 answer

setting font-lock-face to different values for different major-modes

I am trying to set for example font-lock-comment-face to Blue for csharp-mode and for c++-mode to Red is this possible or not? Right now im using: (set-face-attribute 'font-lock-comment-face nil :foreground "#57a64a") (set-face-attribute…
Julius
  • 192
  • 1
  • 9
4
votes
2 answers

Fontifying variable references within string literals in Emacs font-lock-mode

When I type the following code in Emacs ruby-mode, the "#{foo}" is fontified in a different color than the enclosing string. How do I do this in my own Emacs mode? I tried to decipher the ruby-mode source code but couldn't understand it in a…
debeige
4
votes
0 answers

Why does scrolling in Emacs become so slow when a file has more than 2000 lines?

I have some files which are more than 2000 lines. It's very painful to edit these files because editing will become very slow and so does scrolling (scroll up, scroll down, page up, page down). I have tried to solve this problem based on the…
algking
  • 367
  • 3
  • 7
4
votes
2 answers

Context-sensitive font-locking in emacs

Basically, I'm trying to syntax highlight the following piece of coffeescript code the way I want it. Explanation of the syntax of coffeescript functions can be found here. nameHere = (tstamp, moo, boo) -> ... The names tstamp, moo and boo…
Björn Lindqvist
  • 19,221
  • 20
  • 87
  • 122
4
votes
2 answers

Emacs syntax highlighting of optional parts

I'm trying to write a derived mode from fundamental-mode. Assuming that I have this regexp : A ((foo)bar)? B, how can I tell emacs to use the following faces ? font-lock-keyword-face on A font-lock-warning-face on foo (but not…
Maël Nison
  • 7,055
  • 7
  • 46
  • 77
4
votes
1 answer

Lisp regexp matching numbers with or without constant type identifiers ( 3.2 or 3.2f )

Question: I'm looking to create a number font-lock face in emacs but I'm having trouble getting a regular expression that matches what I need. Here is what I have: "\\<\\([0-9]*\\.?[0-9]*\\)+\\(d\\|f\\)?\\>" What I want it to match: 2 2.1 2.1f or…
Jordon Biondo
  • 3,974
  • 1
  • 27
  • 37
3
votes
1 answer

highlight "" in strings for emacs

I am a bit of an emacs noob, but not quite sure how to even find this. I use solarized light color theme, which is a low contrast theme with intelligent accents to keep things readable. One thing they do in the vim version is highlight the string…
Matt Briggs
  • 41,224
  • 16
  • 95
  • 126
3
votes
1 answer

How do I make emacs render mathematical combining characters in font-lock mode?

I am trying to get emacs to properly render mathematical combining characters such the diaeresis, over bar, etc in font-lock mode. The goal is to be able to write something mathematical like x_dot and have it be displayed as "ẋ", or x_bar as…
ivar
  • 1,484
  • 12
  • 20
3
votes
2 answers

How to use emacs/elisp to highlight parts of font-locked source code

I have some log files that contain the directory paths and file names (and line numbers) for C++, C, Java and C# source code files. I have written a regex to search for these file names and line numbers and open the source code file and position the…
Siegfried
  • 695
  • 1
  • 9
  • 24
3
votes
1 answer

why does syntax highlighting disable when I use web-mode in emacs?

This is my init.el (require 'web-mode) (setq web-mode-tag-auto-close-style 1) (setq web-mode-enable-auto-closing t) What should I do?
faara
  • 159
  • 1
  • 1
  • 5
3
votes
6 answers

Emacs - color of directories in dired

I have search the web. I have tried color-theme (perhaps I need to create my own, but really I have my emacs set up the way I want it except for this ONE thing, and I could not find a color theme that was acceptable to me). I just want to change…
nroose
  • 1,689
  • 2
  • 21
  • 28
3
votes
0 answers

In emacs, how to colorize a row in a CSV based on value in a column?

I have created a major-mode for emacs that I use for data analysis. This mode works great for me but it's drab and I don't take advantage of color the way I should. The data being analyzed is in a CSV format and I'd like to colorize the rows…
unclejamil
  • 445
  • 3
  • 10
3
votes
2 answers

How to test `font-lock-keywords` values for Emacs Lisp code

I pose the question because I think both the question and possible answers might help Emacs users who write Lisp code that defines font-lock-keywords. I'm providing one answer that I think helps. I'm also interested in other answers. That…
Drew
  • 29,895
  • 7
  • 74
  • 104
3
votes
3 answers

Make everything a little more colorized

Is there anything I can add to emacs that will make as much as possible in as many modes as possible colorized, including bold and italic?
themirror
  • 9,963
  • 7
  • 46
  • 79