Fix & document set-pretty-symbols!
This commit is contained in:
parent
fff9547763
commit
2a125000ae
1 changed files with 36 additions and 6 deletions
|
@ -40,21 +40,50 @@ universal way of getting the correct symbol as that area varies from font to
|
||||||
font.")
|
font.")
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defvar +pretty-code-symbols-alist nil
|
(defvar +pretty-code-symbols-alist '((t))
|
||||||
"An alist containing a mapping of major modes to its value for
|
"An alist containing a mapping of major modes to its value for
|
||||||
`prettify-symbols-alist'.")
|
`prettify-symbols-alist'.")
|
||||||
|
|
||||||
|
;;;###autodef
|
||||||
;;;###autoload
|
|
||||||
(defun set-pretty-symbols! (modes &rest rest)
|
(defun set-pretty-symbols! (modes &rest rest)
|
||||||
|
"Associates string patterns with icons in certain major-modes.
|
||||||
|
|
||||||
|
MODES is a major mode symbol or a list of them.
|
||||||
|
PLIST is a property list whose keys must match keys in `+pretty-code-symbols',
|
||||||
|
and whose values are strings representing the text to be replaced with that
|
||||||
|
symbol. If the car of PLIST is nil, then unset any pretty symbols previously
|
||||||
|
defined for MODES.
|
||||||
|
|
||||||
|
The following properties are special:
|
||||||
|
|
||||||
|
:alist ALIST
|
||||||
|
Appends ALIST to `prettify-symbols-alist' literally, without mapping text to
|
||||||
|
`+pretty-code-symbols'.
|
||||||
|
:merge BOOL
|
||||||
|
If non-nil, merge with previously defined `prettify-symbols-alist',
|
||||||
|
otherwise overwrite it.
|
||||||
|
|
||||||
|
For example, the rule for emacs-lisp-mode is very simple:
|
||||||
|
|
||||||
|
(set-pretty-symbols! 'emacs-lisp-mode
|
||||||
|
:lambda \"lambda\")
|
||||||
|
|
||||||
|
This will replace any instances of \"lambda\" in emacs-lisp-mode with the symbol
|
||||||
|
assicated with :lambda in `+pretty-code-symbols'.
|
||||||
|
|
||||||
|
Pretty symbols can be unset for emacs-lisp-mode with:
|
||||||
|
|
||||||
|
(set-pretty-symbols! 'emacs-lisp-mode nil)"
|
||||||
|
(declare (indent defun))
|
||||||
(dolist (mode (doom-enlist modes))
|
(dolist (mode (doom-enlist modes))
|
||||||
(if (null (car-safe rest))
|
(if (null (car-safe rest))
|
||||||
(setq var nil)
|
(delq (assq mode +pretty-code-symbols-alist)
|
||||||
|
+pretty-code-symbols-alist)
|
||||||
(let (results merge key alist)
|
(let (results merge key alist)
|
||||||
(while rest
|
(while rest
|
||||||
(setq key (pop rest))
|
(setq key (pop rest))
|
||||||
(pcase key
|
(pcase key
|
||||||
(:merge (setq merge t))
|
(:merge (setq merge (pop rest)))
|
||||||
(:alist (setq results (append (pop rest) results)))
|
(:alist (setq results (append (pop rest) results)))
|
||||||
(_
|
(_
|
||||||
(unless (plist-member +pretty-code-symbols key)
|
(unless (plist-member +pretty-code-symbols key)
|
||||||
|
@ -63,5 +92,6 @@ font.")
|
||||||
(char (plist-get +pretty-code-symbols key)))
|
(char (plist-get +pretty-code-symbols key)))
|
||||||
(push (cons sym char) results)))))
|
(push (cons sym char) results)))))
|
||||||
(unless merge
|
(unless merge
|
||||||
(assq-delete-all mode +pretty-code-symbols-alist))
|
(delq (assq mode +pretty-code-symbols-alist)
|
||||||
|
+pretty-code-symbols-alist))
|
||||||
(push (cons mode results) +pretty-code-symbols-alist)))))
|
(push (cons mode results) +pretty-code-symbols-alist)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue