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
23 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
15 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
30 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
139 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
32 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
33 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
23 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
vote
1answer
27 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
1answer
34 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
1answer
25 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. */ ...
3
votes
1answer
56 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. ...
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. ...
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 ...
4
votes
1answer
110 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 ...
1
vote
1answer
88 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
120 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 ...
0
votes
0answers
25 views

Customize the colour of term in description list

Currently the term and its description doesn't look different at all from each other (I have attached a image). I want the term to have a different colour, preferably red. I found some resources on ...
1
vote
1answer
93 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
40 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 ...
1
vote
1answer
52 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
55 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 ...
1
vote
1answer
92 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 ...
0
votes
0answers
33 views

Changing colors of text between two pre-specified markers

I am editing some TeX files, in emacs in which contains lots of text between @{ and @} markers. Is it possible to modify TeX's highlighting so that text between those brackets get colored in yellow, ...
1
vote
0answers
73 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 ...
0
votes
2answers
49 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 ...
1
vote
1answer
38 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 ...
3
votes
2answers
44 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 ...
3
votes
0answers
35 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
42 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 ...
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 ...
3
votes
0answers
139 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
1answer
46 views

Determine the face(s) that would be applied to a character inserted at point, after font-lock does its thing?

Suppose I am trying to write a major mode. In this mode, certain ordinary characters should have special "electric" behavior when typed, but only in some contexts (e.g. in code but not in strings or ...
0
votes
1answer
46 views

with-temp-buffer removes text properties

Given e.g. (with-temp-buffer (clojure-mode) (insert ":hello") (buffer-string)), I'd expected the result to be propertized, however it isn't. How to get a propertized string out of a temporary buffer?
0
votes
1answer
407 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 ...
1
vote
0answers
85 views

Fix org-mode agenda highlighting

I'm having an issue with highlighting in Org agenda: Can't make the link and tags Gray when the item is marked as Done. I've tried to play with different properties of the font-lock definition, but ...
1
vote
2answers
146 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
2answers
89 views

ANSI / xterm font-locking

I have a buffer with terminal escape codes in it and I want them to be colored: I was able to do this with (ansi-color-apply-on-region (point-min) (point-max)): However, my file is really big and ...
2
votes
1answer
66 views

Why can't I fontify an indirect buffer?

I like using indirect buffers and narrowing to work on multiple sections of code simultaneously. I noticed recently that if I disable font-lock-mode in an indirect buffer then I cannot get proper ...
1
vote
0answers
46 views

No font lock in org-mode

When I the first time enter an org-mode buffer, I get no font lock at all unless I revert-buffer or reopen the file. Even I turn on the debug mode, no error is emit. How should I debug and fix this?
2
votes
1answer
56 views

Preventing syntax highlighting in the wrap-prefix

When Emacs wraps long lines, is there a way to prevent the wrap prefix from having syntax highlighting (font-lock) or any such special properties? Specifically, I have the following settings: ;; ...
1
vote
1answer
125 views

Replacing autoref command format specification in auctex's font-latex-match-reference-keywords-local

With some help I have redefined the autoref command to take an optional argument, see https://tex.stackexchange.com/questions/428229/autoref-with-optional-argument-text-in-generated-link Now I am ...
0
votes
1answer
86 views

Search based fontification not working

In trying to learn Emacs Lisp on Emacs 25.3.1, I decided to implement a minimal version of fic-mode. Following is the code: (defun todo/pos-in-doc-or-comment-region-p (pos) (memq (get-char-property ...
0
votes
1answer
94 views

Highlight (and increase font) for specific words in the buffer when it's opened

I'm looking for functionality that will allow me to highlight specific words of text when I open the buffer in specific mode, like it should work if you're in js2-mode web-mode vue-mode and the ...
0
votes
1answer
105 views

Highlight a buffer with custom programming language syntax

I have files which are not .py but they are python code. I want to highlight them as if they were python files. How can I do that.
1
vote
0answers
44 views

Font-locking for text inside org-mode COMMENT blocks

While other sorts of #+BEGIN ... #+END blocks seem to get font-locking applied to them (potentially changing foreground and background colours etc.), #+BEGIN_COMMENT ... #+END_COMMENT blocks do not. ...
2
votes
2answers
960 views

Display another symbol than asterisks in org headings

I would like to change the way headings render while still using the * to type headings (so this question is distinct from Change the asterisk (heading identifier) to some other symbol in Org mode) I ...
2
votes
2answers
159 views

font-lock for \left and \big in auctex

I am trying to replicate http://endlessparentheses.com/improving-latex-equations-with-font-lock.html with no success, I get a "defface for ‘endless/unimportant-latex-face’ fails to specify containing ...
1
vote
1answer
169 views

Fontify source code blocks with Org 9.0

Is there a way to do syntax highlighting in org-mode code blocks without using: (setq org-src-fontify-natively t)? Since v. 8, I have been unable to fontify the background for org-block with this ...
6
votes
1answer
430 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
44 views

Unable to run browse-kill-ring

After installing the browse-kill-ring package under Emacs 24.5.1, I get the following error when running the browse-kill-ring command: font-lock-set-defaults: Wrong type argument: symbolp, (font-...