7

I think this will do it. (require 'python) (setq python-font-lock-keywords (append python-font-lock-keywords '(;; this is the full string. ;; group 1 is the quote type and a closing quote is matched ;; group 2 is the string part ("f\\(['\"]\\{1,3\\}\\)\\(.+?\\)\\1" ;; these are the {keywords} ("{[^}]...


4

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, your function. Note that by default it highlights inside the "parens" of each scope.


3

You can simulate the \ze construct using repeated matching. See also (info "(elisp) Search-based Fontification"). (defun my-matcher (limit) (when (re-search-forward "\\([0-9]\\{1,3\\}\\)\\(?:[0-9]\\{6\\}\\)*\\(?:[0-9]\\{3\\}\\)\\_>" limit t) (goto-char (match-beginning 1)) (re-search-forward "[0-9]+" (match-end 1)))) (font-lock-add-...


2

You do not need to modify web-mode.el. You just add a new font-lock keyword in web-mode-hook. The code below demonstrates that. You can store it in your init file. (defface my-web-mode-hl__lg '((t (:foreground "#ff007c"))) "Face for the first arg of __lg.") (defun my-web-mode-hl__lg () "Configure web mode such that the first arg of __lg(...) is high-...


2

Based on the examples in section Customizing Search-Based Fontification of the elisp manual, I would propose this: (add-hook 'clojure-mode-hook (lambda () (font-lock-add-keywords nil '(("\\(@\\)" 1 '(:foreground "red") prepend))))) This uses an anonymous face with red foreground, any face could of course be used.


2

Here's my attempt. I learnt org-font-lock-set-keywords-hook on https://www.gonsie.com/blorg/org-highlight.html. The org-green face is defined in @amitp's answer. (defun org-add-my-extra-markup () (add-to-list 'org-font-lock-extra-keywords `(,(rx (group "{{") (group (+? anything)) (group "}}")) ...


2

There are two things you want. Apply a face (green text) to the area between {{ and }}. Hide the {{ and }}. For the first, you can define a green face and then use font-lock to mark the text: (defface org-green '((t :foreground "green4")) "Face for green text in org mode") (defun my/org-mode-font-lock () (font-lock-add-keywords nil '(("{{\\(.*...


2

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 not highlighted grey. In addition to the difference you spotted in printf, this is also visible in other places like the braces and parentheses.


2

highlight-numbers mode will provide color for all numbers in a buffer, and you can use it in your R process buffer. It only supports a single highlight, so you can't use a different color for positive and negative numbers. However, you can tweak it to highlight only negative numbers, leaving the other numbers to be colored according to ESS's font-locking. ...


1

Emacs provides a general-purpose highlight mechanism which might work here. See Interactive Highlighting in the Emacs manual. The relevant commands are highlight-phrase or highlight-regexp to define what you want to highlight (and in what color). You can ask Hi Lock mode to save the highlight instructions in the file itself using hi-lock-write-interactive-...


1

AUCTeX fontifies all control words: For known ones (added in font-latex.el or via AUCTeX style files), it uses different classes (e.g., warning, function, textual etc.) and for unknown ones, it simply uses the font-latex-sedate-face which defaults to Foreground: DimGray. You can customize this face if you want a different appearance. There is no ...


1

These syntax-table settings imply that there are 4 comment-start markers: /* of style a -- of style b -* of style a /- of style b IIUC two of those are undesired and need to be "weeded out" via syntax-propertize-function.


1

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 set the opening and closing clauses for whatever nested syntax you have, and that block will be highlighted in a submode. M-x package-install RET graphql-mode M-...


1

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 :inherit nil :background "gray80") (global-hl-line-mode 1)


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