Last active
May 17, 2022 04:15
-
-
Save tungd/6242039 to your computer and use it in GitHub Desktop.
WIP Highlight `printf` format string specifier token.
Used some code from: http://www.emacswiki.org/emacs/AddKeywords#toc7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar font-lock-format-specifier-face | |
'font-lock-format-specifier-face) | |
(defface font-lock-format-specifier-face | |
'((t (:inherit font-lock-preprocessor-face))) | |
"Font Lock mode face used to highlight format specifiers." | |
:group 'font-lock-faces) | |
(defun highlight-format-specifier () | |
(font-lock-add-keywords | |
nil '(("\".*\\(%\\(?:[-+0-9\\$.]+\\)?[bdiuoxXDOUfeEgGcCsSpn]\\)[^\"]*\"" | |
1 font-lock-preprocessor-face t)))) | |
(add-hook 'prog-mode-hook 'highlight-format-specifier) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Differencies from the Emacs Wiki version: