refactor(ligatures): set-font-ligatures!: unsetting multiple modes
This changes set-font-ligature such that unsetting multiple modes will properly manipulate multi-mode entries in ligature-composition-table.
This commit is contained in:
parent
ef142fc913
commit
0ce403d069
1 changed files with 17 additions and 15 deletions
|
@ -60,22 +60,24 @@ For example, the rule for emacs-lisp-mode is very simple:
|
||||||
|
|
||||||
This will ligate \"->\" into the arrow of choice according to your font.
|
This will ligate \"->\" into the arrow of choice according to your font.
|
||||||
|
|
||||||
Font ligatures can be unset for emacs-lisp-mode with:
|
All font ligatures for emacs-lisp-mode can be unset with:
|
||||||
|
|
||||||
(set-font-ligatures! \\='emacs-lisp-mode nil)
|
(set-font-ligatures! \\='emacs-lisp-mode nil)
|
||||||
|
|
||||||
Note that this will keep all ligatures in `+ligatures-prog-mode-list' active, as
|
However, ligatures for any parent modes (like `prog-mode') will still be in
|
||||||
`emacs-lisp-mode' is derived from `prog-mode'."
|
effect, as `emacs-lisp-mode' is derived from `prog-mode'."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
;; NOTE: Doom enforces `ligature-composition-table' to have a single mode per
|
(after! ligature
|
||||||
;; key in the alist. This is less efficient than what ligature.el can do
|
(if (or (null ligatures) (equal ligatures '(nil)))
|
||||||
;; (i.e. use a list of modes, or `t' as a key), but holding this invariant
|
(dolist (table ligature-composition-table)
|
||||||
;; allows resetting with `(set-font-ligatures! 'mode nil)` to work reliably.
|
(let ((modes (ensure-list modes))
|
||||||
(if (or (null ligatures) (equal ligatures '(nil)))
|
(tmodes (car table)))
|
||||||
(dolist (mode (ensure-list modes))
|
(cond ((and (listp tmodes) (cl-intersection modes tmodes))
|
||||||
(delq! mode ligature-composition-table 'assq))
|
(let ((tmodes (cl-nset-difference tmodes modes)))
|
||||||
(let ((package? (featurep 'ligature)))
|
(setq ligature-composition-table
|
||||||
(dolist (mode (ensure-list modes))
|
(if tmodes
|
||||||
(if package?
|
(cons tmodes (cdr table))
|
||||||
(ligature-set-ligatures mode ligatures)
|
(delete table ligature-composition-table)))))
|
||||||
(setf (alist-get mode +ligatures-alist) ligatures))))))
|
((memq tmodes modes)
|
||||||
|
(setq ligature-composition-table (delete table ligature-composition-table))))))
|
||||||
|
(ligature-set-ligatures modes ligatures))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue