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
3
votes
0 answers

emacs minimap: how to highlight functions using semantic/face

I am trying to customize the minimap package in emacs. I'd like to be able to read the name of the functions, class, etc while in the minimap. The effect I am trying to achieve is this (although in python mode): (from…
ajeje
  • 590
  • 5
  • 11
3
votes
1 answer

customize emacs mode and font-lock-defaults

I am writing a minor mode for HTML/PHP templates. I have a var with PHP keywords (defvar web-mode-php-keywords '("array" "as" "break" "catch" "continue") "PHP keywords.") This var is used for font-locking like this : (defvar…
fxbois
  • 806
  • 9
  • 21
2
votes
1 answer

Defining new keywords with font-lock-add-keywords breaks/overrides variable-name coloring (emacs)

I was trying to get emacs to color some additional keywords in C. In particular, I to add RESTRICT. I did: (add-hook 'c-mode-common-hook (lambda () (font-lock-add-keywords nil '(("\\<\\(RESTRICT\\)\\>" .…
ehliu
  • 21
  • 1
2
votes
1 answer

Custom C preprocessor format in Emacs cc-mode

I'm generating a C source file from a Mako template. Mako templates have directives similar to C preprocessor directives, except that they start with % instead of #. For example: %if some_condition: /* Condition is true */ %else: /* Condition…
Jmb
  • 18,893
  • 2
  • 28
  • 55
2
votes
2 answers

Force fontification of another buffer

Let us assume I have registered a function as fontification in a buffer named foo. With jit-lock-mode: (jit-lock-register #'(lambda (start end) (message "Jit!"))) From another buffer, I would like to force that fontification function…
BiagioF
  • 9,368
  • 2
  • 26
  • 50
2
votes
2 answers

How to change color of a certain string in Emacs?

Let's say I want all words "bad" be red (#ff0000). What should I add to init.el so the color of the string/word "bad" will turn red in all modes whether it is org mode or some other mode into this: https://i.imgur.com/7WMwG1s.png I would like to do…
jilocoiner
  • 105
  • 5
2
votes
1 answer

remove-text-properties doesn't seem to affect `display` text property

I'm confused why using remove-text-properties to remove the display text property doesn't change the display in the buffer. Instead it seems I must completely remove all the text properties using set-text-properties to nil. For example, why doesn't…
Rorschach
  • 31,301
  • 5
  • 78
  • 129
2
votes
1 answer

emacs font-lock-mode for JavaScript: would like to highlight 'self' just like 'this'

Because I often have to preserve this from getting overwritten in closures, I like to do: var self = this; at the top of my constructors. I'd like to subsequently highlight self exactly how and when this is currently highlighted. However after…
BaseZen
  • 8,650
  • 3
  • 35
  • 47
2
votes
2 answers

Font lock with org-agenda not working

I have a org file with the following content: * My Heading ** TODO Make a FOO ** TODO Take action on bar and FOO ** TODO Check if FOO is working My objective is to highlight the word FOO from the task headings in org-agenda-mode. To achieve this,…
Rafael Ibraim
  • 1,515
  • 2
  • 12
  • 13
2
votes
2 answers

How to distinguish Python strings and docstrings in an emacs buffer?

If I have just (set-face-foreground 'font-lock-comment-face "red") (set-face-foreground 'font-lock-string-face "green") in my .emacs, emacs uses the same font-lock for Python strings and for Python docstrings. What should I add to my .emacs so…
Calaf
  • 10,113
  • 15
  • 57
  • 120
2
votes
1 answer

font-lock-mode in haskell-mode seems to ruin the width of single spaces in emacs

I find that font-lock-mode are doing something wrong with the width of single spaces no matter what monospace font I'm using. Here are some screenshots: Using DejaVu Sans Mono: font-lock-mode on: font-lock-mode off: Using Luculent: font-lock-mode…
Javran
  • 3,394
  • 2
  • 23
  • 40
2
votes
2 answers

How to set emacs operator color?

How can I set font color for operators? I'm programing in C++, and I would like operators such as '+', '=', '!=', '<<' and such be colored as I wish. I tried move the cursor onto an operator and 'M-x customize-face' but it takes me to 'all faces'…
Diaz
  • 957
  • 2
  • 13
  • 22
2
votes
1 answer

ELisp Syntax Table Comments for Haskell style comments

I am attempting to set up Haskell style comments using ELisp Syntax-Table-Comments but I can't quite get it. In Haskell, there are 2 basic types of comments -- denotes a single line comment ending with \n {- denotes a multi line comment ending with…
Joe
  • 1,534
  • 9
  • 19
2
votes
1 answer

Change font lock interactive ESS buffer

I use ESS to run R and sometimes evaluate long blocks of code interactively. I'd like errors to stick out in the interactive process. Currently, Error: messages generated by R appear in a greenish-blue font lock color. I'd like something more…
Charlie
  • 2,801
  • 3
  • 26
  • 27
2
votes
1 answer

structural view of source code in emacs

some times i have comments to my code at different structure levels, for example the following python code: # level one comment for i in list: # level two comment if mod(i, 2): # level three comment print 'odd number' …
shelper
  • 10,053
  • 8
  • 41
  • 67