25
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
...
24
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 ...
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 ...
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)...
11
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 ...
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 ...
10
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 ...
10
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 ...
8
votes
Highlight current line without changing colours
Just for reference, try
(set-face-attribute 'hl-line nil :inherit nil :background "gray6")
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 ...
7
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.
...
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 ...
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-...
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 :...
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 ...
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 ...
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 ...
5
votes
Accepted
How to highlight graphql template literals (gql) in js(x) files?
I've found a solution using the emacs package mmm-mode. Most of the information I got was from this article.
What this package does, is allow multiple major modes in the same buffer. You basically ...
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 ...
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 ...
4
votes
Accepted
add a rule to syntax-propertize-rules
The answer is that you can't do it "right".
But you can do the following:
(defalias 'my/perl-syntax-propertize-function
(syntax-propertize-rules ("\\('\\)[bh]" (1 "."))))
(add-hook 'perl-mode-hook
...
4
votes
Don't switch to math-mode when entering `$` in a `minted` environment
I'd like to give an answer which is complementary to the one given by @Tyler.
I'd recommend that you set this in your init file:
(setq TeX-parse-self t)
restart your Emacs and open your .tex file ...
4
votes
Accepted
Syntax highlight doxygen comments in C/C++? (c-doc-comment-style)
Posting own answer since I didn't find an existing method *.
This is generic Doxygen highlighting,
it doesn't try to be too strict since doxy supports so many different expressions.
\[anything] and @...
4
votes
How to change syntax highlighting for mode?
In Emacs, syntax highlighting is performed using the module font-lock. It highlights a buffer in two phases:
The syntactic phase, where comments and strings are highlighted.
The keyword phase, where ...
4
votes
Accepted
How to activate AUCTeX support for beamer without preamble?
First of all, I suggest you create a proper class file beamer-preamble.cls like this:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{beamer-preamble}
[2017/04/26 v0.1 My Beamer Preamble]
\LoadClass[<...
4
votes
How to highlight the current scope with C family languages?
A bit long in the tooth, but still seems to work fine, highlight-sexp will do what you want. Move out of your inner if, it highlights the entire for block. Out again, the entire outer if. Out again, ...
4
votes
Defining color for "$"variable in bash
Emacs calls syntax highlighting “font lock”. Specifically, font lock is the part of syntax highlighting that parses the text to determine what parts are comments, keywords, variable names, etc., and ...
4
votes
Accepted
Ligatures without font-lock
Like a comment on the reddit thread you linked says, Emacs with HARFBUZZ support can use https://github.com/mickeynp/ligature.el (available on Melpa as ligature)
My config for Julia Mono:
(use-package ...
3
votes
How can I get regexp-opt (or similar) not apply on the word with added underscore?
\< and \> match word boundaries.
Assuming _ is a symbol-constituent character in the buffer in question, you want to use \_< and \_> to match the beginning and end of the symbol.
See C-...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
syntax-highlighting × 245font-lock × 53
org-mode × 42
highlighting × 18
python × 17
major-mode × 17
syntax-table × 15
latex × 13
c++ × 11
comment × 11
org-export × 10
colors × 10
regular-expressions × 9
auctex × 8
syntax × 8
faces × 7
web-mode × 7
indentation × 6
org-babel × 5
themes × 5
string × 5
perl × 5
c × 4
cc-mode × 4
spacemacs × 3