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
0answers
13 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
26 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" "*{")) ...
2
votes
1answer
54 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
35 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 ...
3
votes
1answer
59 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
59 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
23 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 ...
0
votes
0answers
44 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
19 views

How to hilight 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
11 views

Overriding preprocessor font-lock behavior in major mode derived from c-mode

I have a custom language that mostly follows C syntax, but uses (only) # for comments instead. I want to build a major mode with font locking for it. I've got it mostly working, by deriving from c-...
0
votes
0answers
47 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
41 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
43 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
32 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
197 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
125 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
99 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
18 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
39 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
39 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 ...
0
votes
0answers
18 views

Using extended glob quantifiers break Zsh mode indenting and highlight

This is a small issue, but annoying to deal with. Suppose I have the following function: function zicompinit_fast () { setopt extended_glob local_options autoload -Uz compinit local zcompf="...
0
votes
0answers
45 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
51 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
39 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
41 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 ...
2
votes
1answer
26 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 ...
0
votes
0answers
16 views

Fontify broken url link in org-mode & HTTP 443 error

It's known that we can fontify broken file link as discussed here, but If I do something similar concerning broken url link... (defun org--url-face (url) "Define a dynamic face for url links." (...
0
votes
1answer
50 views

How to use faces to enhance text

I'm writing some very simple code to get data from a web api, i then parse the response and output the result in a buffer. By default this text is very flat, how can i add keyword highlighting that ...
0
votes
0answers
33 views

Editing mode for OpenBSD .conf files

Can GNU Emacs edit OpenBSD configuration files (/etc/*.conf, curly-brace syntax) with auto-indentation and syntax highlighting? conf-mode does not seem to handle that syntax in Emacs 26. c-mode ...
2
votes
1answer
26 views

Giving faces compliant names

The description of defface in (info "(elisp) Defining Faces") says that the name of a face should not end in -face. But most faces declared in font-lock.el do use the suffix -face. How does this fit ...
1
vote
1answer
47 views

How to force all fontification to complete?

I have a package which checks the face of a character before operating on it. A problem with this is, the face might not yet have been calculated because of:jit-lock-context-time, which delays ...
1
vote
0answers
27 views

Incorrect font locking/syntax hightlighting in c-mode

I've recently started using Emacs, and I'm having a problem with the font-locking in c-mode. I'm using the Monokai theme, and I'm finding that some tokens are being coloured incorrectly. The problem ...
1
vote
1answer
41 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,...
1
vote
1answer
16 views

visit new file; enter shell script text; without saving/reloading, fontify the buffer to sh-mode

The title of this question basically says all. Visit a new buffer, let's say 'foo'. Enter shell script text in the new buffer, let's say "#!/bin/sh". How can I now set the mode to sh-mode and ...
0
votes
1answer
47 views

How to highlight a single word in comments, which matches a function call?

While there are packages that handle this, I would like to highlight a single word in source code comments, using for example the warning face, when a function call returns t, using the word as input. ...
0
votes
1answer
56 views

Is it possible for multiple modes to combine their fontifications?

For example, a buffer has some major mode and it does its own fontification. If I turn on a minor mode A then it adds its own fontification which changes the existing fontification by changing the ...
1
vote
1answer
60 views

Why needs syntax highlighting often a `revert-buffer`?

Quite frequently, syntax highlighting in a given buffer is broken (i.e., a big fraction of the code is not highlighted). This is definitely not due to syntax errors, and the point at which ...
0
votes
0answers
59 views

Why is Emacs hanging or seeming like it isin an infinite loop?

In my current Emacs major-mode for Tecplot macro development, I have a few functions defined: (defconst tecplot-macro-mode-syntax-table (let ((table (make-syntax-table))) ;; ' is a string ...
0
votes
0answers
38 views

applying an underlined font-lock-face style to source code

I'm trying to build an interactive query builder for tree-sitter in Emacs with highlight for matches as underlined text instead of overlays. So far I nailed most of the code to accomplish this, the ...
0
votes
1answer
53 views

How do I build a regexp that enables Emacs to set all words to the left of an equal sign a specific font-lock-*-face?

Following some help provided by Tobias, I am trying to assign a font-lock-keyword-face to all text (:alpha:) to the left of an equal sign (=) in a new Tecplot major mode. I read through the regexp ...
0
votes
1answer
99 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,...
0
votes
1answer
54 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 ...
0
votes
0answers
84 views

disable syntax highlight on inactive windows

I got the following code for highlighting inactive and active windows with different background color. How do I make so that inactive windows have no syntax highlighting, only the active window has? ...
2
votes
1answer
97 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 ...
1
vote
2answers
74 views

Syntax highlighting in sql-mode on Emacs-24 not working?

I'm trying to get the font-lock stuff in plsql.el (https://www.emacswiki.org//emacs/plsql.el) to work in Emacs 24 (that's the version provided by my Linux distro), but it doesn't highlight ...
0
votes
1answer
88 views

Automatically highlight elements in an XML buffer

I spend a lot of time in XML buffers using nxml-mode (Emacs 26). Out of hundreds of XML elements, I am only interested in one or two. How can I have Emacs always show the XML elements I'm interested ...
2
votes
1answer
61 views

How can a list of fields be colored with different colors?

Here's a line from an SQL dump with randomized contents: REPLACE INTO `drxneuleqtx` (`qd`, `mva`, `cuqtgwm`, `vatoj`, `mrfdgnaheui`, `pacc`, `aaqfjhkv`, `epue`, `kvaerg`, `xevtan`, `vmvwwgci`, `...
0
votes
1answer
99 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....
1
vote
1answer
60 views

Regex search contains font-lock strings

I am searching in a buffer for a regular expression by this snippet: (setq jb-revision-version "\\([[:digit:]]+\\.?\\)") (setq jb-revision-string "\\(\\(Revision\\|Id\\): +\\)") (progn (save-...
4
votes
1answer
54 views

How to highlight digit groups of 3 in numerals?

I find it very useful to visually distinguish every 3 digit group of numbers in source code so that I can read it. For example something if I see 1000000 it is fairly easy to see that this is 1M ...

1
2 3 4 5