Questions tagged [syntax-highlighting]

is the feature of displaying text, especially source code, in different colors and fonts according to the meaning of different terms.

Filter by
Sorted by
Tagged with
9
votes
2answers
4k views

The syntax highlight and indentation of source code block in exported html file for org-mode

When I insert C code block inside an org-mode file, the syntax highlight and indentation of the source code are customized as I wanted. When I export it into a html file, the syntax highlight in the ...
2
votes
4answers
677 views

How can I stop emacs from highlighting whitespace?

After a recent update, my Perl files are rendered like this: Note that trailing spaces are shown in red and empty lines in yellow. This is happening despite my having the following in my ~/.emacs: (...
3
votes
1answer
192 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 ...
1
vote
1answer
522 views

Haxe-mode broken in Emacs 24.4

Installing Emacs 24.4 broke my haxe mode. The mode for the HaXe language doesn't seem to be maintained any more so I'm trying to fix it myself. Firstly, I had a cl-macroexpand-all problem which ...
1
vote
0answers
788 views

syntax highlighting and auto-completion for CSS?

How can I set up css-mode for syntax highlighting and autocompletion? I installed web-mode, but it doesn't seem to be giving me any of those features.
12
votes
1answer
1k views

How to get rainbow-delimiters/rainbow-blocks to highlight in-line math in LaTeX equations

I'm using spacemacs with AUCTeX for LaTeX editing and would like to make rainbow-delimiters and/or rainbow-blocks highlight LaTeX math equations. Unfortunately this only works partly, i.e., some ...
5
votes
3answers
438 views

Saving and restoring highlighting patterns

I have some log files that I spend a lot of time reading, and I find myself doing the same series of commands to get useful highlighting each time I open a new log. Typically some combination of M-x ...
5
votes
2answers
161 views

How do I handle multiple string delimeters in a major mode?

I'm trying to write a major mode for a language that supports normal strings and triple-quoted strings ("foo" and """foo"""). (defconst my-string-mode-syntax-table (let ((table (make-syntax-table)))...
11
votes
1answer
1k views

How do I specify a custom face with font-lock-defaults?

If I define font lock keywords using existing faces, I can highlight the string 'foo'. (defconst my-mode-font-lock-keywords (list (cons "foo" 'font-lock-type-face))) (define-derived-mode my-...
8
votes
2answers
448 views

How can I nest one syntax table in another?

I've written a simple mode for handling JSON. It uses the derived machinery to re-use most of json-mode's code. However one addition is you can insert elisp into the JSON text which is evaluated at ...
10
votes
2answers
358 views

Why don't major modes just inspect the faces?

When writing a major mode, it's often useful to know 'is point in a string?' 'is point in a comment?'. Most major modes seem to attempt to parse the programming language. For example: python-syntax-...
15
votes
1answer
2k views

syntax highlighting in source blocks

I thought that org-mode highlighted source blocks with the relevant mode. So for example: #+BEGIN_SRC clojure (defn plus [a b] (+ a b)) #+END_SRC This would show up with the syntax highlighting ...
2
votes
1answer
273 views

Flycheck and OpenMP pragmas for GCC

I'm using Flycheck with GCC as my checker for C. However, Flycheck gives warnings on OpenMP pragmas, regardless of whether they're correct or not! Is there any setting I can change to turn off these ...
7
votes
1answer
340 views

How can I prevent python-mode from occasionally highlighting everything as string

I use python-mode for my Python code, and every once in a while the syntax highlighter gets confused and thinks everything in the buffer is a string literal. This typically seems to happen when I ...
7
votes
1answer
661 views

Change syntax highlighting without changing major mode?

I want to start a python-shell M-x python-shell. If I'm not happy with the syntax highlighting, is it possible to improve it (put more colors in the buffer) without changing major mode? In vim this ...
6
votes
1answer
369 views

Applying major-mode font locking to exported org-babel snippets

Currently I have a bunch of code snippets in my Org-based presentation. I'm exporting them with ox-reveal, but the exported code doesn't have any syntax highlighting. Is there any way to: have syntax ...
12
votes
2answers
477 views

For what languages is `syntax-ppss` appropriate?

I've been looking at a way of detecting whether point is on a comment by looking at how the current buffer is fontified. Smartparens defines sp-point-in-comment, which relies on syntax-ppss. However, ...
4
votes
1answer
707 views

Why do sql-mode and sql-interactive-mode not highlight strings the same way?

Here is a screenshot showing the difference between sql-interactive-mode (top) and sql-mode (bottom). Why does the string not get highlighted properly in sql-interactive-mode? (Note - this also ...
8
votes
1answer
271 views

How do I create a simple syntax table for a major mode?

I'm trying to understand how syntax tables work, but my minimal major mode doesn't highlight anything. I've written the following elisp, which is just supposed to highlight comments: (defconst my-...