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
2
votes
0answers
69 views

Changing background color based on first character on line

How can I change the font background based on the first character on a given line? Take for example: (set-face-attribute 'marker-2 nil :background some_function) where some_function returns "blue" ...
6
votes
3answers
2k views

How do I debug an "Invalid face reference: quote" message?

After using Emacs for some time, the message Invalid face reference: quote starts popping up in my message buffer. I'm not sure what causes it to start appearing. debug-on-message doesn't do anything ...
7
votes
1answer
2k views

How to highlight specific keywords inside strings/quotes?

I have another syntax highlighting for SQL keywords inside strings (inside quotes) in VIM. It looks like this: Then in Emacs with PHP-mode, everything between quotes (') will be considered as a ...
1
vote
1answer
94 views

How can I highlight different keywords according to a suffix?

I want to highlight foo in foo:: without highlighting foo::<bar>, using font-lock-keywords. This is the result I want: Initially I tried this: (defvar example-font-lock-keywords `((,(rx (...
2
votes
0answers
421 views

Emacs/ESS/Org hangs/spins on yank

I have the following Emacs org buffer that I'm editing: #+BEGIN_SRC R regimes <- read.spreadsheet(wlda, 3) %>% within({ TurbineID <- paste(Site, Turbine) Date.of.Change....
5
votes
0answers
87 views

How to replace a character display only for the `italic` face?

I am using a font that does not include italic characters. However, it does include characters like mathematical italic small a, which I would like to use instead. I can set up a display-table that ...
0
votes
1answer
366 views

How to change the font-lock string definition?

I wrote a simple mode with the following font-lock definition, which defines just some keywords: (defvar marpa-mode-font-lock `((,(regexp-opt '(":default" "action" "lexeme" "default" "latm" "...
5
votes
0answers
111 views

Fontify result of source block in org-mode [duplicate]

Let's say I have a source block containing a shell command that outputs some C code. For instance #+BEGIN_SRC sh :results verbatim :exports both echo 'const char* str = "foo";' #+END_SRC #+RESULTS: :...
0
votes
1answer
106 views

Why does font-lock for comment work in cpp, but not in c?

This comment gets font-lock-comment-face in C++ mode, but not in C mode: /** * \file test.cpp * */ If I add another * to /** -> /***, it's working in C-mode, too... I'm not aware of any ...
3
votes
1answer
673 views

Emacs 25: org-mode fontification error

There are two other questions asking this, but one accepted an answer that didn't help, and the other lacked detail. To reproduce: Ubuntu 14.04 running emacs-snapshot from ppa.launchpad.net/ubuntu-...
1
vote
1answer
410 views

White borders around text with theme org-beautify-theme

I'm using these themes in my init file (it's literally all that is in my init file): (add-to-list 'custom-theme-load-path "~/.emacs.d/themes") (load-theme 'org-beautify-theme t) (load-theme 'zenburn ...
2
votes
1answer
2k views

Org-mode font size changes with formatting

In Windows I've set my default font height to 120 with: (set-face-attribute 'default nil :height 120) This seems to not take effect in org-mode, however, when specially formatting is applied. For ...
6
votes
1answer
1k views

Syntax highlighting for comments in text mode

From time to time I open a script or config file for which there is no major mode defined. When I invoke comment-region within that buffer, Emacs will prompt me for the comment syntax, and save it as ...
5
votes
2answers
76 views

Let-bind a variable while font-locking

I am writing a font-lock rule that calls a function to decide what face to apply to a symbol. Here's a simplified version: ("\\(?1:\\s_+\\)" (1 (the-function 1))) The problem is that this function ...
1
vote
0answers
406 views

org-mode fontification error

Since some time ago I've been having this message: org-mode fontification error whenever I initialize org-mode by opening an org buffer. The initialization process will just get stuck and I have to ...
4
votes
1answer
347 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 ...
2
votes
0answers
386 views

Is there a way to suppress errors in the *Messages* buffer?

I have a persistent problem with some jit-lock-function somewhere whenever I compile. I'm actually invoking the visual studio compiler, and I assume some of the output is somehow abhorrent to emacs. I ...
14
votes
1answer
2k views

Make org-mode markup symbols invisible?

In Emacs, one can use asterisks * to achieve bold font, for example, *bold*. My question is can I make the asterisks invisible? i.e. bold instead of *bold*. Same question for strike through, italics, ...
11
votes
1answer
1k views

Color declared variables

I'm looking for a simple way to make emacs remember of declared variable in a single function in C/C++. By "simple", I mean without any external package, just with some elisp lines in configuration ...
0
votes
1answer
206 views

Using font-lock with custom faces in nXML mode

I am trying to view XML files in Emacs, but I am not seeing any font highlighting. The entire document appears as white on black (which is my default font). The following note appears on the ...
2
votes
1answer
123 views

Font-lock for strings messes up non-code buffers

In Magit buffers, or helm-swoop, an unclosed double quote enables the string highlighting for the rest of the buffer (until another quote is found). This is how it looks like: Because of that, I also ...
6
votes
1answer
343 views

Why does inserting a newline break highlighting with syntax-propertize-function?

I'm trying to write a major-mode that highlights triple-quoted strings. Here's a minimal reproducible example: (defconst demo-triple-quoted-string-regex (rx "\"\"\"" ;; After the delimiter, ...
14
votes
2answers
767 views

Highlighting shell variables within quotes

In vim, the following document will cause the $PWD on lines 2 and 3 to be colored in two different ways: #/bin/sh echo "Current Directory: $PWD" echo 'Current Directory: $PWD' The first instance of $...
5
votes
1answer
1k views

"Error running timer `font-latex-jit-lock-force-redisplay'" in LaTeX mode

Since an upgrade to GNU Emacs 24.4.1, I Error running timer `font-latex-jit-lock-force-redisplay': (wrong-number-of-arguments (2 . 2) 3) [N times] where N in my observations ranges from single ...
8
votes
4answers
2k views

How can I highlight duplicate lines?

Here's what I have: (defun my-show-duplicate-lines () (interactive) (highlight-lines-matching-regexp (concat "^" (regexp-quote (substring-no-properties (...
7
votes
1answer
93 views

How to highlight text based on regions--not regular expresions

When font-lock-mode is enabled I cannot get custom faces to stick with add-text-properties or set-text-properties. I've looked through libraries like hi-lock.el, but they all seem to be regexp based. ...
2
votes
1answer
121 views

Function coloring in scratch buffer

When I am typing in the scratch buffer, I type certain functions such as defun and while and they are recognized by the buffer and appear in purple. However, with other Lisp functions such as set or +,...
5
votes
2answers
659 views

Three-characters comment syntax

Emacs supports syntax flags for 1- and 2-characters comment delimiters. Can it be made to recognize and properly highlight 3-characters delimiters? For example: In Emacs Lisp: ;;; Headings In C#...
2
votes
1answer
425 views

Repeated regex capture for font-lock

Let's say I have a language which looks like this: anchor (item something item some thing item some item thing) item item and that I'm playing with font-lock a bit. I would like to highlight "anchor"...
1
vote
1answer
294 views

Dollar symbol inside lstlisting block turns on font-latex-math-face

I am using lstlisting to add shell code into my tex document. The shell code contains special character, $. Emacs assumes it as a Math mode mark & all characters that come after dollar symbol are ...
4
votes
1answer
149 views

Can I apply a face to an optional group?

When I try to execute the following, font-lock fails abruptly after it matches the first group. A little bit of debugging with the neat tool font-lock-studio and I realized that font-lock is upset ...
1
vote
2answers
466 views

Regexp to font-lock numbers but not strings?

I would like to have my dollar sign yellow coloured. So after searching around, I learnt that the Emacs regex's are different from default regexs. After a while, I got this worked: (defface font-...
6
votes
1answer
182 views

How can I fontify a symbol by regexp match group (as in a naming convention)?

I want to add better support for expl3 to AUCTeX. I have regular expressions that properly group according to the naming conventions for: functions (\\(?:__)?[a-z]+_)([a-z_]+)(:[nNpTFwcVvxof]*), ...
5
votes
2answers
2k views

Can I add highlighting in a minor mode?

I'm trying to understand minor modes with the goal of adding a minor mode for Jinja2 syntax highlighting (from jinja2-mode) to stuff like YAML. I'm running into problems though. When following a ...
3
votes
5answers
983 views

How to use font-lock to highlight end-of-line comments?

I am trying to add a comment feature to json-mode. A comment starts with a hash sign and ends at the end of the line. However, if the hash sign is inside a string it should not count as the start of ...
5
votes
2answers
742 views

Color-code a new generic character combination

I'm new to Emacs and Org-mode, this is a very basic question. Unfortunately the keywords are too common for me to find the answer. I would like to create a custom pattern to colour my writing input. ...
9
votes
2answers
2k views

How to implement the piping operator %>% in ESS mode?

Recently, R witnessed the smart introduction of the piping operator %>% or then operator in code which I use quite frequently nowadays. I wonder if this has already been implemented in the newest ...
0
votes
0answers
269 views

How to do font-lock of double quotes in AUCTeX?

I had a hard time typing with Rt-to-Lt language and using quotes in LaTeX while keeping the font-locking of quotes. I use csquotes package latest version (Version 5.1d -- 2011) for many advantages ...
7
votes
1answer
357 views

Use font-lock mode on only part of buffer

I am trying to add a comment feature to Pod documentation for Perl scripts, and I would like to highligh Pod comments with a special face. A simple prototype Perl script could be: #! /usr/bin/env ...
3
votes
1answer
208 views

How do I highlight certain words between double quotes with font-lock?

I'm trying to add additional colors to json-mode for when I edit json-schema. I can get it working fine without searching for double quotes, but I need to for some highlighting. I've tried quite a ...
3
votes
1answer
601 views

How to add more fontify rules

I'm following the instruction at http://www.emacswiki.org/emacs/AllOut#toc3 to have the allout mode fontify its headers (enclosed below). It works but the existing major mode's fontifying effort ...
13
votes
3answers
1k views

Fontify a region of a buffer with another major mode

I have a buffer that shows documentation for Ansible modules. This buffer has its own major mode which provides all the standard stuff. Notably, it fontifies the buffer to highlight inline markup, ...
14
votes
1answer
2k views

Optimizing font lock performance

I want to perform a variant of anchored font lock matching. I have function definitions that start with a list of names, and I want those names to be highlighted inside the function body. I have ...
6
votes
1answer
529 views

Function matcher with font-lock-keywords anchored highlighter

I can highlight text like the following: constant:'variable,variable' with code like this which uses the anchored matcher form: (font-lock-add-keywords nil '(("\\(constant\\):'" (1 font-lock-...
4
votes
1answer
266 views

How can I apply faces interactively under `font-lock-mode`?

font-lock-mode sets font lock for the entire buffer -- normally to provide syntax highlighting. Sometimes though, when I'm preparing a tutorial, I want to call attention out to certain lines. It ...
3
votes
1answer
184 views

Emacs 24.4 no longer highlights keywords in `M-x run-python`

With Emacs 24.3 I get certain keywords highlighted in an inferior Python buffer: This is no longer the case for Emacs 24.4: What could possibly cause this? I've made sure it's not my configuration ...
7
votes
1answer
171 views

Modify org-mode's definition of comment lines?

Q: how do I change org-mode's definition of a commented line? According to the manual, org-mode comments work as follows: Lines starting with zero or more whitespace characters followed by one '#' ...
3
votes
1answer
358 views

Hexl-mode with colors?

I have just been using Hexl-mode to investigate some binary files. What I would like though, is some way of highlighting the byte under consideration: at the moment the line and column indices are ...
6
votes
2answers
1k views

Change the way CC-mode font-lock the C++11 `auto` syntax

With C++11, the keyword auto attained a new syntax and semantics. However, it seems that CC-mode has not been aware of this. For example, if I write auto var = exp, I get var in green, in which ...
4
votes
2answers
756 views

CC-Mode - Javadoc Comment Colors in C/C++

I've been fiddling around a bit with CC-mode lately and figured that since I prefer to comment my functions/classes with javadoc-like syntax, I'd like to use the built-in comment highlighting provided ...