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
0answers
55 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
59 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 ...
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
1answer
65 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
87 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?
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 ...
1
vote
0answers
250 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 ...
2
votes
2answers
592 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 ...
6
votes
2answers
191 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 ...
4
votes
1answer
168 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
128 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
68 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
254 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
173 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
179 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
399 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
56 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. ...
3
votes
2answers
2k 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
205 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
448 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
1k 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
53 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-...
0
votes
0answers
151 views

Prettify string, find by regex

I want to replace the regular expression `.*` by bolding .* and not displaying the backticks. So I want `elem` to become elem I looked into these questions about how to prettify strings rather than ...
1
vote
1answer
65 views

Switching » and « in tex-mode

In tex-mode, the font lock mechanism treats characters between « and » as quoted text. This is fine for French and Norwegian, which use the quotation marks «thus». But in German and Danish the ...
3
votes
1answer
72 views

How to syntax highlight text which is not already highlighted?

I'd like to highlight function calls in C code, eg: (font-lock-add-keywords 'c-mode `((,(concat "\\([_a-zA-Z][_a-zA-Z0-9]*\\)" ; Object identifier "\\s *" ; ...
1
vote
0answers
40 views

`htmlize` not taking CIDER font-locking into account

I'm using htmlize to give Org-mode code blocks syntax highlighting when exported as HTML, but the exported code only captures some of the font-locking. In particular, for Clojure, it does not capture ...
2
votes
0answers
200 views

org-pretty-entities for markdown-mode

org-mode has the variable org-pretty-entities that allows for the display of LaTeX math as unicode characters. How could one get the same result in markdown-mode? It seems like this should be a ...
1
vote
0answers
141 views

How to highlight fragments of source and example blocks within an org-mode buffer itself

This is a variation on the theme of How to <mark> code fragments in org-export. Here the question is about making portions of src and example blocks stand out (preferably without breaking the ...
2
votes
0answers
202 views

How can I make hl-line mode not override the color of rainbow-mode? [duplicate]

Is there an non-intrusive way to do this? I've made a fork of rainbow-mode that uses overlay instead of text properties, which solves this :) https://github.com/amosbird/rainbow-mode
1
vote
1answer
239 views

Font lock of inline code in org-mode?

When using org-mode as a front-end to LaTeX, I'm making heavy use of inline code like @@latex:\textit{something italic}@@. Right now, this is mainly displayed as normal text (with proportional font ...
3
votes
1answer
763 views

How to change the appearance of list bullets in LaTeX/beamer exports?

It's very neat that simple org-mode lists get exported to itemize (or enumerate) environments in LaTeX. Yet I would like also to be able to change the face of an \item bullet using square brackets, as ...
0
votes
1answer
138 views

Default syntax highlighting as in "emacs -Q"

I want to use the syntax highlighting that you get when running emacs -Q. If I run emacs -q, or run Emacs with no ~/.emacs file existent, or not load any custom theme, I get a dark-backgrounded color ...
5
votes
1answer
2k 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 ...
1
vote
0answers
458 views

How can I dynamically set the column width that I'd like to font-lock?

My init currently has the following: (defun font-lock-width-keyword (width) ...
1
vote
3answers
227 views

Highlight a comma-separated list by using rx macro

I want to create font locking for string like: interface Foo extends B, C, D, E {}; And I can't understand why my regexp rule doesn't work for font locking: (defvar my-font-lock-keywords `( ;;...
1
vote
0answers
56 views

derived mode for Pandoc Templates

I am trying to derive mode based on Sample Mode. Reduced contents here: ;;; pandoc-template.el --- Pandoc-Template major mode ;; Copyright (C) 2017 ;; Author: VaclavHaisman ;; Keywords: extensions (...
0
votes
1answer
358 views

Adding new syntax highlighting for some major modes does not work

My question is similar to this one and that one: I would like to add highlighting of some characters that are not highlighted in some programming modes, like python-mode and fortran-mode. So, ...
1
vote
1answer
1k 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: ;; ...
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 ...
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
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[...
2
votes
1answer
2k views

Python mode - custom syntax highlighting

I am an Emacs newbie and trying to work out how to implement custom colors. Currently I have a conditional statement and a while statement which both use the same face (font-lock-keyword-face). Is ...
1
vote
1answer
97 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
0answers
97 views

Drunken font lock in a long-running session

I'm running the emacsformacosx.com build of Emacs 25.2.1 in daemon mode. I connect to it through emacsclient invoked from various tmux sessions in macOS Terminal. $TERM is xterm-256color. The daemon ...
1
vote
1answer
552 views

replace checkbox with glyph via font-lock

I am trying to figure out how how to replace structural elements in org-mode with glyphs/abbreviations to make them more readable. Unfortunately, I'm getting stuck on replacing a simple checkbox [X] ...
1
vote
1answer
266 views

Poor's man way to debug font-lock matcher functions?

I was told on Reddit that font-lock-studio will help me debug a matcher I was working on, however, I find myself with one more problem than before as I need to learn edebug and also grasp how to debug ...
0
votes
1answer
241 views

How to highlight other square brackets in custom major mode?

I'm working in a custom major mode, and part of the syntax are the square brackets, like [Hello world] and so they can contain nested square brackets as in [Hello [World]], however I see this problem ...
1
vote
1answer
223 views

Best way to implement dynamic highlighting

I am working on a minor mode that will use Slime to highlight defined symbols when editing Lisp code. The code is here. It is based on the code for Highlight-Defined which registers a matcher function ...
5
votes
2answers
207 views

How can I get a font-locked string just as substring it from a buffer under specified major mode?

Suppose I have a python-mode user buffer with content import os, I can use (buffer-substring (point-min) (point-max)) to get a colorized string #("import os" 0 6 (fontified t face font-lock-keyword-...
0
votes
1answer
30 views

Apply a background to code with font-lock

I have a command file that uses syntax such as -TAG <ARGS> -TAG- to pass arguments to a sub program. I want to Highlight everything between the opening and closing tags with specific background ...