24 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 ...
wasamasa's user avatar
  • 22k
21 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 ...
Jason Blevins's user avatar
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 ...
Hariharan's user avatar
  • 473
12 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, ...
finalpatch's 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.
Jordon Biondo's 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 ...
Tobias's user avatar
  • 32.8k
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)...
Oyren's 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 ...
John Kitchin's user avatar
  • 11.6k
10 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 ...
rasmus's user avatar
  • 2,712
9 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 ...
John Kitchin's user avatar
  • 11.6k
9 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 ...
Stefan's user avatar
  • 26.3k
8 votes

Highlight current line without changing colours

Just for reference, try (set-face-attribute 'hl-line nil :inherit nil :background "gray6")
Yadoo86's user avatar
  • 81
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 ...
deadghost's user avatar
  • 807
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 *" ...
Martin R. Albrecht's user avatar
6 votes
Accepted

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

FWIW, I just pushed support for "proper" highlighting of f-strings in Emacs's master branch, so it will be available in Emacs-28 when that gets released (and is available in GNU ELPA's ...
Stefan's user avatar
  • 26.3k
6 votes

minor mode to display long integers?

I did some searching and surprisingly couldn't find any existing minor modes that seemed to do this. I thought it would be a fun little project, however, so I've written a minimal minor mode (rainbow-...
D. Gillis's user avatar
  • 486
5 votes

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

color-identifiers-mode does this for variables, if I understand your question correctly. rainbo-identifiers-mode too, I think. Screenshot is from the former one.
Alejandro Erickson's user avatar
5 votes
Accepted

LaTeX Mode and Listings with $-signs?

Syntax highlighting would be correct if file parsing is enabled. First check whether the options suggested at the beginning of the AUCTeX manual are enabled: (setq TeX-auto-save t) (setq TeX-parse-...
JeanPierre's user avatar
  • 7,363
5 votes
Accepted

Line highlighting canceling out syntax highlighting

Basically, the hl-line face is defining a :foreground property, which is overriding the other foreground colors in your theme. misterioso defines hl-line in terms of highlight using inheritance, and ...
PythonNut's user avatar
  • 10.3k
5 votes
Accepted

Treat shebang as a comment

Try (modify-syntax-entry ?# ". 1" js-mode-syntax-table) (modify-syntax-entry ?! ". 2b" js-mode-syntax-table) Reference
Michael Vehrs's user avatar
5 votes

Highlight current line without changing colours

This is the case by default for me: hl-line-mode by default uses a face which only specifies a background color. That face is hl-line which by default just inherits from highlight. So maybe the ...
Stefan's user avatar
  • 26.3k
5 votes

Highlight current line without changing colours

This works for me, with this in my .emacs. See how the syntax colours are nicely preserved? (thx Yadoo86) ;; highlight line with the cursor, preserving the colours. (set-face-attribute 'hl-line nil :...
ohainaut's user avatar
5 votes

Adding new commands to the syntax highlighting of a language mode

You can do this using the function font-lock-add-keywords. It takes two arguments, the first is the major mode to extend. Alternatively, you can pass nil which mean the current buffer, which is useful ...
Lindydancer's user avatar
  • 6,105
5 votes
Accepted

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

You can add minted environments to the latex-verbatim-environment variable: M-x customize-variable latex-verbatim-environments, insert a new string "minted", and save your changes. You may need to ...
Tyler's user avatar
  • 21.9k
5 votes
Accepted

Why does text surrounded by tildes in org mode turn grey

Tildes are used for marking something as code/monospace. See Emphasis and monospace in the Org manual. Your whole buffer might be monospace in Emacs (depending on your settings) so the gray is a ...
glucas's user avatar
  • 20.4k
5 votes

org-mode batch export: Missing syntax highlighting

You have already mentioned that emacs skips the personal initialization files if it is called with --batch. Therefore, you need to call package-initialize yourself if you want to use package.el. ...
Tobias's user avatar
  • 32.8k
5 votes
Accepted

How does org-mode implement syntax highlighting for code blocks?

It uses cc-mode. It copes the text to a temporary buffer, highlights it using the major mode that is associated with the language, and copies back the highlighting. In addition, it makes everything ...
Lindydancer's user avatar
  • 6,105
4 votes
Accepted

Syntax highlight narrowed python string literals as code

This can be done with polymode. (require 'polymode) (defcustom pm-host/python (pm-bchunkmode "python" :mode 'python-mode :font-lock-narrow nil) "Python host ...
PythonNut's user avatar
  • 10.3k

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