29 votes
Accepted

Extending org-mode with more markups

I have done something similar. It's in French, but the code should speak for itself. I use ‰ for the marker (I use a bepo layout), and when I do, the marked text as a pressed-button style. I am not ...
user avatar
23 votes
Accepted

Export code blocks in org-mode with minted environment

You will need to tell Org to Use minted for listings Include minted in the default package list Change the compilation switches to accommodate for minted: (setq org-latex-listings 'minted ...
user avatar
  • 21.1k
18 votes

Github-flavored markdown mode: syntax highlight code blocks

Native syntax highlighting of code blocks is now part of the current development version of Markdown mode. Specifically, it works for those GFM or tilde-fenced code blocks for which the language name ...
user avatar
16 votes
Accepted

syntax highlighting in source blocks

Org-mode fontifies these blocks if you enable the corresponding setting. Try: (setq org-src-fontify-natively t)
user avatar
  • 21.1k
13 votes

Can I highlight Lisp like this?

With show-paren-mode you can highlight the whole expression. You need to have the following code in your init file. You can try different style and choose what you like to highlight. (show-paren-mode ...
user avatar
  • 463
12 votes
Accepted

Why don't major modes just inspect the faces?

The problem is that it is not more robust. Firstly, the major modes are precisely the ones responsible for deciding what's a comment or a string. If they were able to successfully define them for the ...
user avatar
  • 22.4k
11 votes

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

The solution for this spans elisp, org-mode and css customization. elisp By default, the fontification information is embedded in the exported html file. We need to disable that and tell org-mode ...
user avatar
  • 24.3k
11 votes

Better syntax-higlighting for member variables and function calls in cpp-mode

The Emacs one is actually better. Here's why, The purpose of syntax highlighting in text editors is not being pretty, but to make important code structures stand out. If you look at the Emacs sample, ...
user avatar
11 votes
Accepted

Which mode to use for ECMAScript 6?

js2-mode supports all of this. It is available on GNU ELPA and MELPA for easy access.
user avatar
11 votes
Accepted

How to highlight specific keywords inside strings/quotes?

The following elisp snippet should do. The important details are: Strings are handled by syntax highlighting and not by pattern matching (i.e., keyword highlighting). This has very high priority. So ...
user avatar
  • 30.5k
11 votes

Exporting highlighted source code to pdf in Org-Mode

Hey this answer solved my similar problem. A bit late but I had the same issue today. As mentioned, I add the following code snipped to my .spacemacs/.emacs config: (require 'org) (require 'ox-latex)...
user avatar
  • 221
11 votes
Accepted

How to highlight in different colors for variables inside `fstring` on python-mode

I think this will do it for Emacs versions < 27.1 (require 'python) (setq python-font-lock-keywords (append python-font-lock-keywords '(;; this is the full string. ;; group ...
user avatar
  • 11.1k
10 votes
Accepted

Color-code a new generic character combination

You can use font-lock-add-keywords to add custom highlights. In the below example, I am highlighting any string that begins with _ preceded by a white-space character or beginning of the line ...
user avatar
  • 24.3k
10 votes
Accepted

Three-characters comment syntax

AFAIK the example you give are actually 2-char comment delimiters, except that depending on the 3rd character, these comments are treated in different ways (but always as comments in the sense that ...
user avatar
  • 25.4k
9 votes
Accepted

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

Take a look at the C-hv value of font-lock-type-face the value is just the symbol font-lock-type-face. Now look at the C-hv value of my-mode-foo-face. Oh no! you can't! It's not a variable! You need ...
user avatar
9 votes
Accepted

How to get colored syntax highlighting of code blocks in asynchronous Org-mode exports to HTML?

With ox-html? See the docstring of org-html-htmlize-output-type. Output type to be used by htmlize when formatting code snippets. Choices are css to export the CSS selectors only,inline-css to ...
user avatar
  • 2,642
8 votes
Accepted

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

It is correct, but it is not being refontified just because you change major modes. Enable your major mode and put your cursor in the comment then run M-x eval-expression (syntax-ppss-context (...
user avatar
8 votes
Accepted

Web mode HTML tag highlighting

To disable the behavior.. Programmatically: (setq web-mode-enable-current-element-highlight nil) web-mode-enable-current-element-highlight is a variable defined in ‘web-mode.el’. Its value is ...
user avatar
8 votes

What is a string fence or comment fence?

They are documented in the manual, but it doesn't use the word “fence”. The characters ! and | are listed as “generic comment delimiters” and “generic string delimiters” in the syntax class reference. ...
user avatar
8 votes

Syntax highlighting for comments starting with specific sequence of characters

This is what I ended up going with: (defface special-comment '((t (:foreground "#2aa198"))) "Cyan") (font-lock-add-keywords 'clojure-mode '((";-;.*" 0 'special-comment t))) ";-;.*" is regex. 0 ...
user avatar
  • 797
8 votes
Accepted

Fontify broken links in org-mode

In org-9 it might be as simple as this for file links: (org-link-set-parameters "file" :face (lambda (path) (if (file-exists-p path) 'org-link 'org-warning))) For internal links I don't know an ...
user avatar
  • 11.1k
8 votes

Is there a standard mode for .ini files?

conf-mode.el says: This mode is designed to edit many similar varieties of Conf/Ini files and Java properties. It started out from Aurélien Tisné's ini-mode. conf-space-keywords were inspired ...
user avatar
  • 25.4k
7 votes
Accepted

Saving and restoring highlighting patterns

Using a keyboard macro is a valid option, as is defining a custom command. The main advantage of using a keyboard macro is that you don't have to know any Elisp to create it. On the other hand, custom ...
user avatar
  • 14.3k
7 votes

How can I nest one syntax table in another?

Ok, let's get some basics straight. Nesting syntax tables is possible Syntax tables don't have to be global to the entire buffer. You can apply them as text properties to specific regions. This ...
user avatar
  • 22.4k
6 votes

How can I nest one syntax table in another?

You don't want to nest one syntax table (which is a vector structure) inside another, you want to set up a buffer where, depending on the position, one syntax table would be used instead of the other. ...
user avatar
  • 3,278
6 votes

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

When you modify the buffer, only the lines you modified get re-highlighted right away. If the modification affects highlighting of lines futher down, these get re-highlighted later via an idle timer (...
user avatar
  • 25.4k
6 votes
Accepted

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

@lawlist is correct: This question is a (not-so-obvious) duplicate of How to change word wrap highlighting in Emacs on StackOverflow. Since we can't close questions against posts on other ...
user avatar
  • 14.3k
6 votes

Better syntax-higlighting for member variables and function calls in cpp-mode

this seems to answer the member function bit of your question (font-lock-add-keywords 'c++-mode `((,(concat "\\<[_a-zA-Z][_a-zA-Z0-9]*\\>" ; Object identifier "\\s *" ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible