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
2answers
100 views

How to write regex to change the go keywords color?

I want to change the color which in package import go defer in go-mode ,need a regex..these code only change the pacakge word color (defface my-font-lock-gokeyword-face `((t (:foreground "#...
0
votes
1answer
169 views

Highlight syntax of function names and their arguments in custom mode

I'm trying to create a major mode that handles the following syntax: function someName(value1, value2) # some contents end function I'm using the following to highlight the keywords function,...
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 `( ("^\...
5
votes
1answer
202 views

Syntax highlighting is breaking in long bibtex files (spacemacs bibtex layer)

So I have a long papers.bib bibtex file that I edit with emacs (spacemacs bibtex layer), but the syntax highlighting only ever goes about halfway down. Here it is at about line 790: Other times this ...
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
1answer
103 views

font-lock keywords and syntax-table mutually interfering

I would like to define something that font-locks a bit like a new sort of string-literal/comment. I might write: (font-lock-add-keywords 'emacs-lisp-mode (list '("<<.*>>" 0 'my-custom-...
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 ...
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
120 views

Can you configure python-mode, elpy-mode to apply font-locking to imported library functions?

This question is likely an expansion / duplicate of this question: how to highlight imported functions in python code? My .py file looks like this: from math import floor (max(1, 8)) (floor(3.7)) ...
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
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" "*{")) ...
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
1answer
135 views

Prioritize color of emphasis faces in Org headers

Observe the following Org buffer, tested on Emacs with no configuration (emacs -q): Note that bold, italic, and underline are all distinctly fontified in the header. However verbatim and code are not....
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 ...
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 ...
1
vote
1answer
36 views

Face-based replacements

I need to perform this kind of (query-)substitutions in LaTeX code: "fig" --> "figure" But I don't want to match text inside commands e.g. \label{fig:1} or \includegraphics[...
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
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 "...
1
vote
1answer
169 views

Improving org-block-begin-line, splitting in several faces

The face org-block-begin-line allows to customize the first line of the following block #+BEGIN_SRC lang :var arg1=1 arg2=2 ... #+END_SRC However, I would like to customize the faces within the line,...
1
vote
2answers
112 views

Cperl-mode syntax highlighting breaks when inserting a newline into a here doc

in cperl-mode, here docs are colored with a font-lock-string-face. However if you used any function that inserts a newline on a blank line (e.g. M-: (insert "\n")) it will cause all code after the ...
1
vote
1answer
51 views

can show-trailing-white-space be forced to ignore blank lines

I'm trying to use the flag show-trailing-white-space and it usually shows me what I want. I.e., I never want dangling white space at the end of a line containing text. However, between lines of text,...
3
votes
1answer
408 views

Smarter and more efficient way to add font lock keywords to org-mode?

I really hate looking at raw markup in org-mode documents, so I am trying to replace as much of it with symbols as possible. So #=begin_ becomes {, src becomes some-glyph etc. My current approach ...
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
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 ...
4
votes
2answers
145 views

AUCTeX: only use monospace for rendering macros?

I've been using the fontify features of AUCTeX, as well as magic-latex-buffer, to display my TeX code in a more readable way. But I'm wondering if I can crank this up to 11: is there a way to render ...
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-...
9
votes
2answers
2k views

How to implement the piping operator %>% in ESS mode?

Recently, R witnessed the smart introduction of the piping operator %>% or then operator in code which I use quite frequently nowadays. I wonder if this has already been implemented in the newest ...
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'...
102
votes
9answers
37k views

How can I get a ruler at column 80?

As a programmer, I want to see a ruler at a specific column (usually 80), both so I see when I cross that column, but also to see how close I am getting to it so I can reformat my code early. The ...
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
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 ...
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 ...
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:...
10
votes
0answers
200 views

How to investigate "color bleeding"?

I frequently have color-bleed issues in emacs, most often with AUCTeX: all of a sudden and for no apparent reason, the line I'm writing will be fontified as math. First things first: no, I do not ...
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
1answer
73 views

Limit font-lock highliting to first N chars of line

I write regex for font-lock and I know that the date should appear in first 40 chars of line. How can I limit search beyond some limit? I tried to add ^.\\{0,40\\}XXX but Emacs regex . is greedy ...
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-...
1
vote
2answers
1k views

Dynamic syntax highlighting (font-lock-mode) stops working in emacs 25.3

About 15-20 minutes into using emacs my syntax highlighting stops dynamically updating. Instead any new text just uses the color of the text right before it. Any ideas on how to debug this issue or ...
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 ...
12
votes
1answer
515 views

Apply ANSI color escape sequences for Org Babel results

Feature There is a nice built-in Emacs feature to colorize strings with ANSI color escape sequences. So evaluating the following Elisp code, will insert the "Test text" at the point with proper ...
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 ...
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 ...

1
2 3 4 5 6