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
1
vote
1answer
17 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 `( ("^\...
0
votes
1answer
17 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 ...
0
votes
2answers
29 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 ...
0
votes
1answer
21 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 ...
1
vote
1answer
23 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-...
0
votes
1answer
30 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 ...
1
vote
1answer
45 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 ...
0
votes
0answers
18 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 ...
1
vote
1answer
45 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, ...
0
votes
1answer
14 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 "...
0
votes
1answer
35 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 ...
0
votes
0answers
12 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?
0
votes
0answers
48 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 ...
2
votes
1answer
83 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 ...
3
votes
1answer
117 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-...
0
votes
2answers
35 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'...
0
votes
0answers
22 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 ...
1
vote
1answer
27 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 #+...
0
votes
1answer
69 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:...
0
votes
0answers
20 views

Avoid font lock in special strings

Consider the following python code: As you see the content of expr is font locked as string. How can I emacs make to format it as if expr=''' and ''' were gone: Other strings should be font locked ...
3
votes
1answer
77 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 ...
1
vote
0answers
40 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 ...
1
vote
0answers
33 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-...
0
votes
0answers
25 views

How to fontify keyword arguments in `python-mode`?

I'm coding in python and it seems like the python-mode doesn't color the keyword-arguments. Note that I'm not talking about general keywords but keyword-arguments. As an example, in the next picture, ...
0
votes
0answers
31 views

*compilation* buffer doesn't show colours until focussed

I am using Emacs 26.3 on Ubuntu 20.04. When I run a command (say, clang) through the (compile ...) function, colors that should have been visible in the output *compilation* buffer are not made ...
0
votes
1answer
51 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 ...
0
votes
0answers
20 views

Format links or dates context sensitive in org-mode headings?

In org-mode I use headings with different font sizes decreasing with the # in org-level-#. In the following Examples, the font size is in brackets and size 5 > size 4 etc. Example: * Heading lvl 1 ...
0
votes
1answer
35 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" "*{")) ...
3
votes
1answer
221 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 (`...
2
votes
1answer
56 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 ...
5
votes
1answer
97 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 ...
0
votes
1answer
91 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 ...
0
votes
1answer
29 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 ...
2
votes
0answers
81 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).
1
vote
1answer
52 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-...
0
votes
0answers
52 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 ...
1
vote
1answer
55 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 ...
1
vote
1answer
80 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, ...
1
vote
0answers
34 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 ...
2
votes
2answers
504 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 ...
2
votes
2answers
231 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 ...
1
vote
2answers
205 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 '(("^ *\\([-]\\) " ...
1
vote
0answers
23 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 ...
3
votes
1answer
57 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 ...
0
votes
1answer
59 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 ...
1
vote
0answers
75 views

Problem with font in markdown-mode table

I am using variable-pitch for markdown-mode. Tables use fixed-pitch (markdown-table-face). The table aligns for regular text. It breaks alignment for links. The spaces are also underlined. ...
2
votes
1answer
52 views

Altering syntax highlighting for a particular expression

In c-mode, I would like all lines beginning with exec sql to have that expression grey and the rest of the line in the default face. How might I achieve that?
0
votes
0answers
54 views

Static function highlighting/locking in C++

In C++ mode, I am finding that static functions are only highlighted when written in the form static ReturnType function_name(args), and not when written ReturnType static function_name(args). Image: ...
1
vote
1answer
58 views

Syntax coloring: Unable to color special syntax

I am writing a mode to color a few common syntax in a symbolic language called FORM. I am a new user of emacs and I took the help of this website to write down the following code. I modified the ...
3
votes
1answer
40 views

Font-lock Yasnippet template from within Org-Babel block

I want to manage my library of snippets from a single org-mode document and tangle these to their respective snippet files, as needed. Now functionally, this works out-of-the box, with the one ...

1
2 3 4 5 6