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
26
votes
2answers
2k views

Extending org-mode with more markups

I want to add a markup and formatting for such markup, i.e. <kbd>...</kbd> with a box surrounds such markup. I also want the mark up to be compatible with (setq org-hide-emphasis-markers t)...
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 ...
12
votes
2answers
2k views

Can I turn off or switch the syntax checker for js2-mode?

I have a default setup of js2-mode. This provides nice syntax highlighting and checking but I am now working on a project with a different set of styles (specifically this new project does not use ...
12
votes
2answers
474 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, ...
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 ...
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-...
11
votes
2answers
4k views

How to get semantic syntax highlighting on emacs for C/C++ code

I'm new to emacs and programming in general so please bear with me. I'm trying to use emacs as my C/C++ IDE, and I noticed that in CC mode the variables/functions seemed to be highlighted only during ...
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-...
10
votes
2answers
447 views

How to add complex syntax highlighting in a minor mode?

I'd like to highlight code with various faces in a minor mode. Here's a screenshot that's close to what I want: One thing that I'm missing is having the comment chars # in font-lock-comment-face. ...
10
votes
1answer
277 views

Highlighting upcoming dates in org mode agenda

I have entries in my org file similar to: * Birthdays :PROPERTIES: :CATEGORY: birthday :END: %%(org-anniversary 1981 1 2) Harry (%d) What I would like is for these to appear in the agenda (say) 2 ...
9
votes
2answers
207 views

What is a string fence or comment fence?

The docstring for modify-syntax-entry says the following: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) ... The first character of NEWENTRY should be one of the following: ... / ...
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 ...
9
votes
3answers
1k views

hl-line-mode hide background, how to avoid this?

With: (when window-system (set-face-background 'hl-line "light yellow") (global-hl-line-mode 1)) current line highlighted by yellow background, but if text has background properties it also ...
8
votes
2answers
444 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 ...
8
votes
1answer
1k views

Which mode to use for ECMAScript 6?

Is there a mode out there that has syntax higlighting (and possibly more, but this is the least I want) for a more recent ecmascript? I'm especially interested in one that has support for template ...
8
votes
1answer
269 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-...
8
votes
1answer
721 views

Fontify broken links in org-mode

If I create a bad [[file:link]] or an internal [[Link]] that does not exist, I would like to org-mode to fontify this using org-warning face. How can I get this done? Thanks,
7
votes
1answer
1k 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 ...
7
votes
1answer
1k views

Github-flavored markdown mode: syntax highlight code blocks

For example, if I have a markdown file with the following: ###This is my markdown file here is some text. here is my code block: ``` js var accountdown = require('accountdown'); var level = require('...
7
votes
1answer
337 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
285 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, ...
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 ...
7
votes
0answers
449 views

How to syntax highlight Python f-strings so {…} uses regular code colors?

Python 3.6 supports F strings, eg: So: print(f'Test {} me!'.format(2 + 2)) Can be written as: print(f'Test {2 + 2} me!') Which print's Test 4 me, Is there a way to adjust emacs syntax ...
7
votes
2answers
156 views

Syntax highlighting fails on clone-indirect-buffer-other-window

I normally use indirect buffers while I edit python code in python-mode, I create them by running clone-indirect-buffer-other-window. While the syntax highlighting of the main buffer looks just fine, ...
6
votes
1answer
4k views

Export code blocks in org-mode with minted environment

After inspecting the LaTeX generated for my org-mode file, I figured out that the code blocks are exported with the verbatim environment. Are there any way to tell org-mode to export code blocks using ...
6
votes
2answers
2k views

Highlight current line without changing colours

I use (global-hl-line-mode 1) in order to highlight the current line. This changes the text colours of the highlighted line. Is it possible to highlight while keeping the current syntax highlighting ...
6
votes
3answers
540 views

Syntax highlighting for comments starting with specific sequence of characters

In clojure, the comment character is ;. clojure-mode syntax highlighting + color scheme greys comment text out. I want emacs to color lines that begin with ;-; with a different color. For example: ...
6
votes
1answer
527 views

Line highlighting canceling out syntax highlighting

I use hl-line-mode and I really like the built-in misterioso theme. However, the way that lines are highlighted with this theme cancels out syntax highlighting or any other properties of the ...
6
votes
1answer
368 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 ...
6
votes
1answer
97 views

How to prevent emacs from fontifying empty part of the line?

As an example, if I start a one line comment: ;; Comment⏎ Emacs will fontify the the whole line, from the beginning of line, occupying the entire width of the window, as comment. This can be made ...
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 ...
5
votes
2answers
412 views

Emacs interface to a pastebin site that supports org-mode-style syntax highlighting?

I've been using emacs-pastebin but all my pastebins wind up as plain text. Is there a way to set emacs-pastebin so that pastebins are set to LISP format by default? Better yet, is there a pastebin ...
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
288 views

Don't switch to math-mode when entering `$` in a `minted` environment

I am using AUCTeX to edit Latex files and use the minted package to highlight source-code within documents. Unfortunately the character $ is still recognized as a delimiter for a math-mode even though ...
5
votes
1answer
1k views

Web mode HTML tag highlighting

First off, a picture of what I see, editing a handlebars file: My colour theme is base16-grayscale, so that blue is probably hard coded somewhere. I asked on the web-mode mailing list, but was told ...
5
votes
2answers
234 views

Highlight as Comment if character is not present

I am writing a simple syntax highlighting mode for a special file type. In the syntax, a line is only valid if it starts with a & character, otherwise it is treated as a comment (basically it is ...
5
votes
1answer
447 views

LaTeX Mode and Listings with $-signs?

I am using LaTeX-Mode and need to include some listings which contain dollar-signs: \begin{lstlisting}[caption=Meteor Server: Bereitstellen einer entfernten Prozedur,label=lst:meteor-server-publish-...
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)))...
5
votes
1answer
207 views

Syntax highlight narrowed python string literals as code

I have some python code, that has some long string literals containing more python code. These strings should most of the time be uniformly colored, as happens by default. However, I would like to be ...
5
votes
1answer
219 views

Highlight matching quotes

Is it possible to highlight matching quotes as show-paren-mode does with parentheses? The characters I'm looking to highlight are "dumb" quotes, both single (Unicode: apostrophe, U+0027) and double (...
4
votes
2answers
554 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#...
4
votes
2answers
596 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. ...
4
votes
3answers
2k views

Syntax highlight doxygen comments in C/C++? (c-doc-comment-style)

Is it possible to syntax highlight doxygen in C/C++ code? QtCreator and Vim both support basic highlighting so \param, \note... etc are highlighted differently.
4
votes
2answers
921 views

How do I turn off syntax coloring for lines that exceed the word-limit in prelude?

I'm using Prelude v 1.0.0. I want to turn off the syntax coloring when my lines exceed a certain word-limit. I don't know where that setting is set. Thanks! EDIT: I should be more precise. Prelude, ...
4
votes
1answer
706 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 ...
4
votes
2answers
83 views

How to highlight the current scope with C family languages?

While it's possible to highlight a block using the character under the cursor, is there a way to highlight the scope of the current cursor? I'm interested in something like QtCreator's block-...
4
votes
1answer
569 views

Set web-mode engine per directory

I'm hoping this is possible. I work in a variety of environments and languages. Right now it's mostly django and Node.js, but there have been others. What I would like to do is set the web-mode engine ...
4
votes
1answer
1k views

Exporting highlighted source code to pdf in Org-Mode

I'm trying to export some python code with syntax highlighted to a pdf, from org-mode. Even though I can export to html without any issues I could not find a way to export it to pdf. n.b. I'm using ...
4
votes
1answer
571 views

How to highlight “constexpr” in cc-mode?

Question Pretty straightforward: How to highlight constexpr in cc-mode (editing C++ code)? Example If I use const as in the following example const double = 3.14 const gets highlighted as a ...
4
votes
1answer
562 views

org-mode batch export: Missing syntax highlighting

I'm having issues achieving any syntax highlighting in the results of the following command: emacs nix.org --batch -f org-html-export-to-html --kill I know this question has been asked a few times ...