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
31 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
22 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
65 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 ...
1
vote
2answers
106 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
71 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
17 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 ...
2
votes
1answer
27 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
33 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
13 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
29 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. ...
1
vote
1answer
45 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
37 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
35 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
24 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
15 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
44 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
26 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
23 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
37 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
36 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
14 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
44 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
51 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
47 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
50 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
23 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
41 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
75 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
47 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
72 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
88 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
46 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
64 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
60 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
90 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
49 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
50 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 ...
0
votes
0answers
31 views

Org-mode source blocks are not fontified same as the corresponding language

i am using Zerodark theme and in my org files I noticed that source blocks (emacs-lisp) are not fontified same as when opening an actual lisp file. I already have this setting: (setq org-src-...
3
votes
1answer
49 views

How to use font-lock to set other text properties (particularly keymap)?

I'm trying to make a mode where certain strings in the buffer have a special keymap active when the point is inside them. The documentation for font-lock-extra-managed-props and the Elisp info manual ...
0
votes
1answer
38 views

font-lock-keywords weirdness

I am trying to modify pandoc-template-mode.el to deal with $$ which is an escape sequence for literal $ inside the Pandoc template. I have added the "\\$\\$" at the top but I still get bad font ...
2
votes
1answer
65 views

AUCTeX fontification for any command: overkill?

Reading the AUCTeX manual I see that it is possible to add expressions to those one wants to highlight in a .tex file. There are also many specific suggestions around for how to add specific commands ...
2
votes
0answers
333 views

Markdown and Latex highlighting (font lock) in R Markdown file

I am using polymode to edit rmarkdown files. Exporting to e.g. pdf is super simple and works very well. R code chunks are also properly highlighted. But: I do quite often use latex code inside (r)...
0
votes
1answer
65 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
60 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-...
1
vote
1answer
168 views

Hi-lock code syntax

I write Hi-lock code at the beginning of tex and org buffers, but it doesn't always behave as I expect it to. What does the number 0 mean in the following? What does it mean when it is 1, instead? % ...
0
votes
0answers
50 views

Retouching syntax highlight of major mode

I am writing a minor mode to complement haskell-mode, and I am trying to color subwords in camelCased identifiers with slightly different shades of the same color. Perhaps this can be done by "...
2
votes
2answers
89 views

Why in dired+ mode some text is strikethrough?

Windows 10, Emacs 26.1, Dired+ (download from here https://www.emacswiki.org/emacs/download/dired%2b.el) Open some directory: Here result: Why some text is strikethrough?
0
votes
2answers
54 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 "#...

1
2 3 4 5