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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

Is it possible to use LSP for font-lock or indentation?

I'm writing C++ and running into problems with font-lock-mode often getting confused by more obscure language features (e.g., operator""_ud). I also find that indentation doesn't work very ...
user avatar
0 votes
0 answers
14 views

How to make custom minor mode on logview mode?

I'm playing with Emacs logview.el to highlight the logs from Synopsys Tools. The logs I want to highlight contains ignorable lines like those below. Warning: Design 'top' contains 23 high-fanout nets. ...
user avatar
0 votes
1 answer
73 views

How to properly use a regex for font locking

I'm stuck with a specific problem, I'm writing a major-mode for a language that supports multiple assignment, meaning that: let s = 9 let x, y, z = 1, 2, 3 var k = 11 var a, c = 4, 5 Are all valid ...
user avatar
0 votes
0 answers
14 views

Make all colors black in the current buffer, without losing other face attributes

I want to disable colors for the current buffer, but preserve boldness, etc. (Which disabling font-lock-mode does not preserve.) The underlying reason is that sometimes the syntax highlighter goes ...
user avatar
  • 620
1 vote
1 answer
40 views

adding highlight to parts of a regexp

I am pretty new to emacs so please excuse the rookie question. So I am editing a helm chart template, and have enabled yaml-mode since most of helm uses yaml. but I wanted to add some highlighting to ...
user avatar
  • 111
0 votes
2 answers
26 views

Customisation for comment delimiter colour based on light or dark theme

I would like to adapt the emacs customisation for comment delimiter colour to change according to light or dark background. How is this customarily done? (defun annot () "Customisation for ...
user avatar
  • 159
1 vote
0 answers
48 views

How to refresh font-lock of the current buffer?

I have a function to highlight custom Scheme syntax: (defun scheme-defmacro (syntax &optional args) (let ((args (or args 1))) (put syntax 'scheme-indent-function args)) (let ((regexp (...
user avatar
  • 1,154
2 votes
1 answer
54 views

Fontify shell commands in org example

I'd like to write examples of shell commands in an Org document: Here's an inlined ~if~ statement: #+begin_example $ if true; then echo hello; fi hello #+end_example I wish for the command part, ...
user avatar
  • 314
0 votes
1 answer
72 views

How can I make `font-latex-sedate-face` have precedence over `font-latex-math-face`?

In LaTeX mode, the face font-latex-sedate-face highlights commands of the form \foo which are not known by AUCTeX. I'd like commands of the form \foo which appear inside a math environment such as \(\...
user avatar
  • 11
1 vote
1 answer
66 views

font-lock not working with my custom face

I defined a custom face (defface my-face '((t . (:background "green"))) "text") that I want to use for font-lock syntax highlighting. (defvar my-font-lock-keywords `( ("^\...
user avatar
  • 13
0 votes
1 answer
35 views

How to replace one face with another for propertized text?

Text with properties can have faces assigned, how can one face be replaced with another? An example use case for this is highlighting some text or it's background. Seeing as Emacs doesn't have the ...
user avatar
  • 7,179
0 votes
2 answers
39 views

Is this syntax parse possible with Emacs' regex expressions?

I'm trying to write a small new mode for some input files to a specific computational physics program. I'm doing it the define-derived-mode way, and was specifying the syntax highlighting by setting ...
user avatar
  • 113
1 vote
2 answers
34 views

Disabling syntax highlighting for specific keywords baked into an optimized regexp

I'm working on a project in Racket, and the syntax highlighting in Emacs' racket-mode is becoming an issue for me. Racket is a highly modular language, and one of the modules that I am not using ...
user avatar
1 vote
1 answer
38 views

After setting syntax-propertize-function, comment is not being fontified with comment face

I'm trying to build a major mode for xwiki, where I'm defining {{{ verbatim }}} as a comment. So far, I've done (eval-when-compile (defconst xwiki-syntax-propertize-rules (syntax-...
user avatar
1 vote
1 answer
55 views

Emacs 28 and python-mode the syntax font-lock-mode seems all off

I wanted to upgrade to emacs 28 to get f-strings support in python but the font-lock.... seem to be all messed up. Sometimes it works as in the past but sometimes it doesn't like why is ...
user avatar
  • 161
1 vote
1 answer
96 views

How to export the current buffer with it's syntax highlighting to a WYSIWYG output?

I would like to use emacs to "render" text to an output file. Is there a way to export the buffer with all font-locking to a file? (The exact format may not matter HTML or terminal-escaped ...
user avatar
  • 7,179
0 votes
0 answers
21 views

What makes the font-lock face of a variable appear and disappear when buffer text is modified?

I am looking into improving electric behaviour and stability of the syntax colourization of Erlang code done by the erlang-mode of erlang.el. While looking into this I noticed that the colorization of ...
user avatar
  • 621
1 vote
1 answer
90 views

Would it be possible apply different font/background color for `<code_sample>` in org mode?

In markdownmode, or while asking questions in stackoverflow, when we do, `<code>` or ```<code>``` The background become changes into gray. Would it be possible to apply same in orgmode, ...
user avatar
  • 1,066
0 votes
1 answer
58 views

How to custom-set-faces with one of the named faces?

I can do this: (custom-set-faces '(j-verb-face ((t (:foreground "Red"))))) But what I want is to set the color to one that is theme-dependent. I tried the following, which causes a "...
user avatar
0 votes
1 answer
49 views

Emacs >27.1: How to highlight in different colors for variables inside `fstring` in python-mode

I am using python-mode which colors the parameters. When I concatinate strings the variable color is represented as different: On the other hand, if I use fstring, the variable is not represented as ...
user avatar
  • 1,066
0 votes
0 answers
14 views

Tone down the bracket match highlighting in LaTeX mode

The LaTeX highlighting is great, but I don't like the way every bracket pair is highlighted — and in such a garish colour. Any thoughts on how to tone this down a bit?
user avatar
0 votes
0 answers
66 views

Highlighting all matched groups in font-lock-add-keywords rule

I'm trying to highlight variable-type in custom let-like form that looks like: (mylet ((<variable-type> <variable-name> <variable-value>) (...)) <some-forms>) To do ...
user avatar
2 votes
1 answer
88 views

Display LaTeX-Quotation marks as unicode characters

When quoting in auctex, I use the strings "` and "' to typeset „ and “, respectively. Now, I want emacs to display the corresponding unicode characters to these strings. I've tried it with ...
user avatar
3 votes
1 answer
218 views

Why does font-lock-mode work with various programming languages but it does not in text-mode?

The objective is to do text highlighting when TODO and NOTE tokens are found somewhere in a txt file. This is what I have in the .emacs.el file: (add-hook 'text-mode-hook 'font-lock-mode) (setq fixme-...
user avatar
0 votes
2 answers
49 views

How to properly use defcustom with backquote / comma grammar? (to edit a mode's font-lock-keywords)

I'm trying to edit a mode's font-lock-keywords variable to use defcustom instead of defconst (which it was using previously). Obviously, this is because I want to be able to easily customize the mode'...
user avatar
  • 1,280
0 votes
0 answers
25 views

Suddenly incorrect fontification of newlines

When a font style is applied to the newline character, certain styles - such as background colors - normally are extended to the end of the visual line. Suddenly this has changed for me, and the fonts ...
user avatar
  • 1,481
1 vote
1 answer
33 views

How to change #+begin_comment .... #+end_comment background and text color?

When I have this code: #+begin_comment So this is my comment's body text. I want it to have these features: 1. text color will be yellow 2. background color will be blue 3. text will be cursive #+...
user avatar
  • 43
0 votes
1 answer
97 views

Can't disable font-lock-mode

If I have font-lock on and I do M-x find-library RET simple RET, I have colours: If I then M-x font-lock-mode to disable the mode, the colours disappear in the currently-visible portion of the buffer:...
user avatar
  • 620
3 votes
1 answer
108 views

Can font faces be dynamically assigned with font-lock-add-keywords?

In all the examples of font-lock-add-keywords I've seen, the font face is static. That is, there is a regex or a matcher function and a literal font face identifier. Is it possible to set the face ...
user avatar
  • 7,179
2 votes
0 answers
50 views

Why is it called "Font Lock" mode?

Just wondering, because ... The function of font-lock-mode is to programmatically un/assign a given typeface or typeface font to text. But it's just an assignment, which can be easily overridden; FLM ...
user avatar
  • 582
2 votes
1 answer
57 views

Additional keyword fontification

How do I add fontification of additional keywords ? This does not work: (add-hook 'c++-mode-hook (lambda () (font-lock-add-keywords nil '(("^\\(trn\\|def\\|mem\\)\\>" . 'font-...
user avatar
0 votes
1 answer
57 views

Highlight all words in a line

Is there an easy way to highlight all the words in a line with just one command? I'm trying to write an elisp function to achieve this but my knowledge is pretty rudimentary. So far, I can only move ...
user avatar
  • 169
0 votes
1 answer
41 views

fontify autoref and nameref in latex-mode buffers

When I'm in a .tex file, press M-: and run (font-latex-add-keywords '(("autoref" "*{") ("Autoref" "{") ("nameref" "*{")) ...
user avatar
3 votes
1 answer
236 views

How to highlight back-tick quoted strings in code-comments?

Since back-ticks are often used for literals, is there a way I can highlight these in code comments? So this: # This is a comment, this is a literal: `4 + 4`. # let's make things interesting (`...
user avatar
  • 7,179
2 votes
1 answer
72 views

Why doesn't font lock work in the minibuffer?

If you invoke M-x eval-expression then you can evaluate elisp expressions there, but there is no syntax highlight. If I turn on emacs-lisp-mode in the eval-expression prompt then the major mode is ...
user avatar
  • 21
6 votes
1 answer
151 views

How to font-lock only strings and comments (syntactic font-locking)?

I generally want font-locking only for comments and strings. This would seem easy to do: customize the relevant font lock faces to make them identical to default. That unfortunately is not ...
user avatar
  • 436
0 votes
1 answer
116 views

How to make org-mode style links?

I have a regular expression and an path, e.g. ("[Bb]ackup" . "/home/user/backup.org"). Now I want every substring in the buffer that matches the regexp to look like an org-link ...
user avatar
  • 2,440
0 votes
1 answer
36 views

Font face (highlighting) of single-quoted strings stopped working after update

I'm using a custom mode that I believe is based on cc-mode, and it's been working great for years. Recently, I upgraded to Ubuntu 20.04, which brought Emacs to 26.3 (I forget what it was before, maybe ...
user avatar
  • 101
2 votes
0 answers
121 views

How to make orgmode decorate quotes?

Org mode decorates some parts of text (like section headers with yellow), but I'd like to add other ones such as double quotes (such as strings when I am editing Lisp code).
user avatar
  • 31
1 vote
1 answer
103 views

How to highlight without one rule breaking another (font-lock-add-keywords)

I have 2 rules and the second one highlighting text disables the first... (font-lock-add-keywords 'org-mode '(("^rtfm .*$" 0 '(:foreground "red")))) (font-lock-add-keywords 'org-...
user avatar
  • 158
0 votes
0 answers
56 views

in Fundamental mode, give certain marked text a different face

I am trying to add a new comment character in fundamental mode, but I can't get it to work. Let me rephrase that, because I think it's an xy-problem. What I really would like to have is the ...
user avatar
  • 131
2 votes
1 answer
73 views

Adding keywords programmatically using the display property

I've added some keywords using the following construct (where tag-todo and tag-note are variable holding a SVG image and tag-key () is a function returning a SVG image): (font-lock-add-keywords nil ...
user avatar
1 vote
1 answer
107 views

Replacing text with svg image via font lock

I've made small function to create SVG tags (see below) and I would like to use the image property of faces to replace some keywords. I'm not sure how to do that and if it is possible. For example, ...
user avatar
1 vote
0 answers
35 views

How to remove fringe when copying from emacs?

When copying from emacs buffers in a terminal to other application, I grab the region and copy them and paste it onto another application. The copied text has a leading whitespace in each line ...
user avatar
  • 355
2 votes
2 answers
759 views

font-lock-add-keywords is not working

So I've been trying to add custom syntax highlighting for digits using font-lock-add-keywords and regex. I've been looking at all the Emacs resources to do this, and while I have been able to ...
user avatar
  • 41
2 votes
2 answers
293 views

How to define custom paragraph types in org mode with custom fontification?

How can I define custom paragraph blocks in org mode with a custom fontification, for example something like #+BEGIN_MYPAR Some text #+END_MYPAR Then I want for example that this block is displayed ...
user avatar
  • 967
2 votes
2 answers
293 views

How to change color of "font-lock-add-keywords"?

I found this piece of code to change org-mode list elements from dashes (-) to circles (•): (font-lock-add-keywords 'org-mode '(("^ *\\([-]\\) " ...
user avatar
  • 3,373
1 vote
0 answers
25 views

Is it possible to have different color values for a font-lock face in a string?

My font-lock-warning-face has a red color. Which works well in almost all circumstances, it is very pronounced. The problem is, my font-lock-string-face has orange color. So warnings inside strings ...
user avatar
  • 127
3 votes
1 answer
80 views

Derived major mode: new keyword fontification not playing nice with parent mode's

I am writing a major mode derived from f90-mode in order to fontify the syntax of a commonly used Fortran preprocessor, fypp (similar to jinja2 for HTML templating). Here's a contrived example of what ...
user avatar
  • 133
0 votes
1 answer
74 views

How to customize font-lock-syntactic-face-function?

I've found I can make some comments use a different face by customizing font-lock-syntactic-face-function. To give some context, I'm setting some comments to use font-lock-doc-face, in situations the ...
user avatar
  • 7,179

1
2 3 4 5 6