Created
February 28, 2016 18:59
-
-
Save rougier/668e9410753fdd43d4a3 to your computer and use it in GitHub Desktop.
Some visible admonitions for emacs
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
(make-face 'face-admonition) | |
(set-face-attribute 'face-admonition nil | |
:height 120 | |
:weight 'regular | |
:foreground "white" | |
:background "light gray" | |
:box '(:line-width 1 :color "light gray")) | |
(defvar face-admonition 'face-admonition) | |
(make-face 'face-admonition-note) | |
(set-face-attribute 'face-admonition-note nil | |
:inherit 'face-admonition | |
:background "royal blue" | |
:box '(:line-width 1 :color "royal blue")) | |
(defvar face-admonition-note 'face-admonition-note) | |
(make-face 'face-admonition-warning) | |
(set-face-attribute 'face-admonition-warning nil | |
:inherit 'face-admonition | |
:background "dark orange" | |
:box '(:line-width 1 :color "dark orange")) | |
(defvar face-admonition-warning 'face-admonition-warning) | |
(make-face 'face-admonition-error) | |
(set-face-attribute 'face-admonition-error nil | |
:inherit 'face-admonition | |
:background "red3" | |
:box '(:line-width 1 :color "red3")) | |
(defvar face-admonition-error 'face-admonition-error) | |
(make-face 'face-admonition-tip) | |
(set-face-attribute 'face-admonition-tip nil | |
:inherit 'face-admonition | |
:foreground "black" | |
:background "light yellow" | |
:box '(:line-width 1 :color "light yellow")) | |
(defvar face-admonition-tip 'face-admonition-tip) | |
(defun admonitions() | |
(font-lock-add-keywords nil | |
'(("\\([ ]+[Nn]ote[ ]+\\):" 1 face-admonition-note prepend) | |
("\\([ ]+[Tt]ip[ ]+\\):" 1 face-admonition-tip prepend) | |
("\\([ ]+[Hh]int[ ]+\\):" 1 face-admonition-tip prepend) | |
("\\([ ]+[Ii]mportant[ ]+\\):" 1 face-admonition-tip prepend) | |
("\\([ ]+[Ww]arning[ ]+\\):" 1 face-admonition-warning prepend) | |
("\\([ ]+[Aa]ttentiong[ ]+\\):" 1 face-admonition-warning prepend) | |
("\\([ ]+[Dd]anger[ ]+\\):" 1 face-admonition-error prepend) | |
("\\([ ]+[Ee]rror[ ]+\\):" 1 face-admonition-error prepend) | |
("\\([ ]+[Cc]aution[ ]+\\):" 1 face-admonition-error prepend) | |
("\\([ ]+[Tt]odo[ ]+\\):" 1 face-admonition prepend))) | |
) | |
;; Add them to the relevant modes | |
;; ------------------------------ | |
(add-hook 'lisp-mode-hook 'admonitions) | |
(add-hook 'text-mode-hook 'admonitions) | |
(add-hook 'python-mode-hook 'admonitions) | |
(add-hook 'markdown-mode-hook 'admonitions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment