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
1answer
62 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....
2
votes
1answer
64 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
21 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
19 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 ...
1
vote
1answer
56 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,...
2
votes
1answer
53 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`, `...
1
vote
1answer
30 views

Basic quote regex for font-locking?

I have my own font locking that highlights quotes in comments eg. /* Some comment 'this is quoted' * more 'text in an escaped \` quote'. * Plurals such as Moe's or Joe's should work too. */ ...
86
votes
8answers
27k 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
76 views

Keymap on region only updating from mouse click

I have defined some keymaps on org-mode src-blocks. If I click in the block with a mouse, I see the keymap is changed, e.g. the menu items change, and the new keybindings are active. However, if I use ...
1
vote
1answer
28 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-...
3
votes
1answer
45 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
vote
2answers
131 views

Fontify headline with todo keyword color

I would like to fontify headlines with the same color/weight as their TODO keywords. So for example, the default is like this: TODO Headline And I want it to look like this: TODO Headline Any ...
3
votes
1answer
881 views

How to make my own org-mode text emphasis work again?

This might be interersting: For quite some time I used the code block below in my custom.el to make my own emphasis definitions. This worked up to org 9, I think. Then all of a sudden when I needed it ...
5
votes
1answer
151 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
0answers
23 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-...
0
votes
1answer
40 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-...
3
votes
1answer
29 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
27 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)) ...
4
votes
1answer
281 views

Highlight HTML entities in Web mode

I often edit articles in web-mode (using PHP). Is there some way of fontifying HTML entities (like &#8211;, &eacute;, and so on)? I'd like them to be a lighter color so that they're easier to ...
0
votes
1answer
31 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
50 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 ...
1
vote
2answers
50 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
1answer
27 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
0answers
79 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)...
1
vote
1answer
145 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
47 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 "...
1
vote
1answer
38 views

How to make font-lock use my face?

I'm interested in making a major mode to display PGN files nicely. I'm trying to create my own faces since the defaults don't seem super-appropriate. My mode definition looks like this: (defface ...
1
vote
2answers
185 views

Why are code blocks and code literals displaying with large face in markdown

In markdown mode, all of the fenced code blocks and inline code literal strings are displaying with this very large font. The size is large, and also I'm pretty sure it isn't the same font as the ...
3
votes
1answer
58 views

Profiling simulated interactive editing

Is there a way to profile or time code that simulates interactive editing? The gist of what I want to do is that I have some code that runs during font-lock, and sometimes it makes editing sluggish. ...
4
votes
1answer
149 views

Is there a way to disable multi-line string literals in c++-mode?

Suppose I have a short string in C++ and I accidentally delete the double quote that ends it. What Emacs does is highlight the rest of the code as a single very long string, which messes up all the ...
6
votes
1answer
542 views

How to highlight graphql template literals (gql) in js(x) files?

Inside of a jsx file, I want to use a gql template literal to define GraphQL queries. Could I in emacs make that section of the jsx file highlight graphql syntax, instead of just showing it as a ...
0
votes
0answers
16 views

Highlight headings in orgstruct-mode

When I do M-x orgstruct-mode (in, e.g. shell script mode, after setting orgstruct-heading-prefix-regexp to "#") and make some comments serve as headings, these comments look like all other comments. ...
0
votes
2answers
336 views

Customize haddock comments color

How can I change the color of the comments starting with -- | in Haskell mode? When I write a comment in Haskell I get a grey face, but when the comment starts with -- |, as required by Haddock ...
1
vote
0answers
41 views

Enable `cc-mode` documentation highlightning per minor mode

I am writing a minor mode for enabling support for JML within Java files. I realized the syntax highlighting with cc-mode's support for documentation comments. It works if I set c-doc-comment-style ...
2
votes
0answers
31 views

Why does setting the 'face property trigger fontification?

I'm trying to write a major mode for a programming language with JSX based syntax. Here's a minimal implementation. (defun example-forward-parse-jsx (start-pos limit) "Move point past the JSX ...
2
votes
1answer
143 views

Replacing a string with symbols using font-lock?

I'm trying to make a font lock hook to replace strings of text for a mathmatical notation plugin. So I'm thinking " / " (note the spaces) will turn into " ÷ ", but "/" won't. (It's a package mainly ...
0
votes
2answers
212 views

hl-line-mode interferes with custom syntax highlighting [duplicate]

Recently, using fic-mode as reference, I implemented a way for words like TODO, etc. to be highlighted. Here is the code: (defun todo/pos-in-doc-or-comment-region-p (pos) (memq (get-char-property ...
1
vote
1answer
704 views

How can I make a custom font-lock keyword regex?

I'm new to emacs (spacemacs) and have been trying to get org-mode to highlight quoted strings "like this" and quoted strings 'like this'. I followed the example here, and came up with this: ;; ...
1
vote
1answer
127 views

highlight-regexp groups for syntax highlighting

I want to highlight certain words to a color using highlight-regexp. The words I want to highlight are "fn", "let", "mut", etc. for rust development. The code I have so far is this: (add-hook '...
1
vote
1answer
47 views

Use `defun` font-locking for other keywords

I'm using the tco.el package, which provides tail-call optimisation for functions in elisp that call themselves in tail-position. The way such functions are identified is by using defun-tco instead of ...
3
votes
2answers
46 views

how can I unit test my font-face rules?

I would like to unit test my font-face keyword rules against some source code data sets. It sounds like it should be quite easy: open the source file, enable the mode, force fontification, dump out ...
1
vote
1answer
54 views

How to defeat the fontification of colour literals in css-mode?

Emacs css-mode is fontifying my colour literals. For example: This makes the text harder to read. I tried to defeat it with the following in my .emacs. (Note: this matches on ‘hsl’ because those ...
0
votes
3answers
61 views

highlight-regexp: what's the variable in which they are stored?

I need to write a macro, with-temp-highlight-regexps, that evaluates BODY and than restores the previous highlighted regexps (created with the highlight-regexp function). I thought I could do it by ...
3
votes
1answer
262 views

How to fully fontify latex snippets including subscript and superscript within org-mode

I have many latex snippets delimited by $ inside my org notes. I recently discovered org-highlight-latex-and-related, which highlights latex snippets a certain face. However, I want to also apply the ...
1
vote
0answers
81 views

Make text Invisible with font-lock-keywords

I'm interested in changing my org-mode buffers to have a better looking logbook. My ideal state to end up in is that text that looks like this: - State "WAITING" from "WAITING" [2018-11-16 Fri ...
1
vote
1answer
40 views

Font lock mode not picking up keywords

Emacs version 26.1, compiled on CentOS 7.5 , running ada-mode 5.3.1. The parser works correctly, but the problem is that keywords aren't being coloured. When I run describe font on the keyword, it is ...
0
votes
2answers
55 views

font-lock limits ignored in anchored matchers

I think I might have found a bug in GNU Emacs but I want to check my understanding first. In Search Based Fontification it is possible to specify a function as a matcher. It must obey the contract ...
3
votes
0answers
36 views

deeply nested loops and conditionals

I am refactoring legacy code. Looks like: for (int i = 0; i < something.length; i++) { .... .... lots of code here .... if (a.good != b.bad) { .... .... .... ...
1
vote
0answers
46 views

EMACS doesn't grey out comments

When I comment out code with combination of /* and */ in JavaScript nothing happens with text and it stays the same color. (You can see it in second part of code, one that is not grayed out but is ...
5
votes
0answers
153 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 ...