2020-08-12 18:52:14 -04:00
|
|
|
;;; ui/ligatures/autoload/ligatures.el -*- lexical-binding: t; -*-
|
2018-07-05 19:37:06 -07:00
|
|
|
|
2020-08-12 18:52:14 -04:00
|
|
|
;; DEPRECATED
|
|
|
|
;;;###autodef
|
|
|
|
(define-obsolete-function-alias 'set-pretty-symbols! 'set-ligatures! "3.0.0")
|
2018-07-05 19:37:06 -07:00
|
|
|
|
2018-07-06 19:59:16 +02:00
|
|
|
;;;###autodef
|
2020-08-12 18:52:14 -04:00
|
|
|
(defun set-ligatures! (modes &rest plist)
|
2018-07-06 19:59:16 +02:00
|
|
|
"Associates string patterns with icons in certain major-modes.
|
|
|
|
|
|
|
|
MODES is a major mode symbol or a list of them.
|
2020-08-20 02:40:57 -04:00
|
|
|
PLIST is a property list whose keys must match keys in
|
|
|
|
`+ligatures-extra-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.
|
2018-07-06 19:59:16 +02:00
|
|
|
|
2020-01-04 04:55:57 -05:00
|
|
|
This function accepts one special property:
|
2018-07-06 19:59:16 +02:00
|
|
|
|
|
|
|
:alist ALIST
|
|
|
|
Appends ALIST to `prettify-symbols-alist' literally, without mapping text to
|
2020-08-20 02:40:57 -04:00
|
|
|
`+ligatures-extra-symbols'.
|
2018-07-06 19:59:16 +02:00
|
|
|
|
|
|
|
For example, the rule for emacs-lisp-mode is very simple:
|
|
|
|
|
2020-08-12 18:52:14 -04:00
|
|
|
(set-ligatures! 'emacs-lisp-mode
|
2018-07-06 19:59:16 +02:00
|
|
|
:lambda \"lambda\")
|
|
|
|
|
|
|
|
This will replace any instances of \"lambda\" in emacs-lisp-mode with the symbol
|
2020-08-20 02:40:57 -04:00
|
|
|
assicated with :lambda in `+ligatures-extra-symbols'.
|
2018-07-06 19:59:16 +02:00
|
|
|
|
|
|
|
Pretty symbols can be unset for emacs-lisp-mode with:
|
|
|
|
|
2020-08-12 18:52:14 -04:00
|
|
|
(set-ligatures! 'emacs-lisp-mode nil)"
|
2018-07-06 19:59:16 +02:00
|
|
|
(declare (indent defun))
|
2018-10-16 17:32:41 -04:00
|
|
|
(if (null (car-safe plist))
|
2018-12-22 04:01:30 -05:00
|
|
|
(dolist (mode (doom-enlist modes))
|
2020-10-15 16:12:57 -04:00
|
|
|
(delq! mode +ligatures-extra-alist 'assq))
|
2020-01-04 04:55:57 -05:00
|
|
|
(let (results)
|
2018-10-16 17:32:41 -04:00
|
|
|
(while plist
|
2020-01-04 04:55:57 -05:00
|
|
|
(let ((key (pop plist)))
|
|
|
|
(if (eq key :alist)
|
|
|
|
(prependq! results (pop plist))
|
2020-08-20 02:40:57 -04:00
|
|
|
(when-let (char (plist-get +ligatures-extra-symbols key))
|
2020-01-04 04:55:57 -05:00
|
|
|
(push (cons (pop plist) char) results)))))
|
2018-10-11 16:06:25 -04:00
|
|
|
(dolist (mode (doom-enlist modes))
|
2020-08-12 18:52:14 -04:00
|
|
|
(setf (alist-get mode +ligatures-extra-alist)
|
|
|
|
(if-let (old-results (alist-get mode +ligatures-extra-alist))
|
2020-01-04 04:55:57 -05:00
|
|
|
(dolist (cell results old-results)
|
|
|
|
(setf (alist-get (car cell) old-results) (cdr cell)))
|
|
|
|
results))))))
|