Include ligature.el in a new set-font-ligatures! function, so that "normal" (read: "font-based") ligatures can also be controlled on a per-major mode basis from a user function in configuration. This commit also drops support for Emacs 27 to reduce the maintenance burden. BREAKING CHANGE: font ligatures for Harfbuzz/Coretext composition table-based ligations are no longer controlled with `+ligatures-composition-alist`, but is handled with `+ligatures-prog-mode-list` and `+ligatures-all-modes-list` for most common cases. See the README for the mode-specific methods BREAKING CHANGE: the `:ui ligatures` module will not work anymore with Emacs 27 or older. Also, there is no need to keep patched fonts (for Fira, Hasklig, Iosevka) if you use the module. Update Emacs if you want to keep using ligatures, or disable the module (`doom doctor` will tell you if your current version of Emacs stopped working with the module)
76 lines
2.8 KiB
EmacsLisp
76 lines
2.8 KiB
EmacsLisp
;;; ui/ligatures/autoload/ligatures.el -*- lexical-binding: t; -*-
|
|
|
|
;; DEPRECATED
|
|
;;;###autodef
|
|
(define-obsolete-function-alias 'set-pretty-symbols! 'set-ligatures! "3.0.0")
|
|
|
|
;;;###autodef
|
|
(defun set-ligatures! (modes &rest plist)
|
|
"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
|
|
`+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 and ligatures previously defined for MODES.
|
|
|
|
For example, the rule for emacs-lisp-mode is very simple:
|
|
|
|
(set-ligatures! \\='emacs-lisp-mode
|
|
:lambda \"lambda\")
|
|
|
|
This will replace any instances of \"lambda\" in emacs-lisp-mode with the symbol
|
|
associated with :lambda in `+ligatures-extra-symbols'.
|
|
|
|
Pretty symbols can be unset for emacs-lisp-mode with:
|
|
|
|
(set-ligatures! \\='emacs-lisp-mode nil)
|
|
|
|
Note that this will keep all ligatures in `+ligatures-prog-mode-list' active, as
|
|
`emacs-lisp-mode' is derived from `prog-mode'."
|
|
(declare (indent defun))
|
|
(if (null (car-safe plist))
|
|
(dolist (mode (ensure-list modes))
|
|
(delq! mode +ligatures-extra-alist 'assq))
|
|
(let ((results))
|
|
(while plist
|
|
(let ((key (pop plist)))
|
|
(when-let (char (plist-get +ligatures-extra-symbols key))
|
|
(push (cons (pop plist) char) results))))
|
|
(dolist (mode (ensure-list modes))
|
|
(setf (alist-get mode +ligatures-extra-alist)
|
|
(if-let (old-results (alist-get mode +ligatures-extra-alist))
|
|
(dolist (cell results old-results)
|
|
(setf (alist-get (car cell) old-results) (cdr cell)))
|
|
results))))))
|
|
|
|
;;;###autodef
|
|
(defun set-font-ligatures! (modes &rest ligatures)
|
|
"Associates string patterns with ligatures in certain major-modes.
|
|
|
|
MODES is a major mode symbol or a list of them.
|
|
LIGATURES is a list of ligatures that should be handled by the font,
|
|
like \"==\" or \"-->\". LIGATURES is a list of strings.
|
|
|
|
For example, the rule for emacs-lisp-mode is very simple:
|
|
|
|
(set-font-ligatures! \\='emacs-lisp-mode \"->\")
|
|
|
|
This will ligate \"->\" into the arrow of choice according to your font.
|
|
|
|
Font ligatures can be unset for emacs-lisp-mode with:
|
|
|
|
(set-font-ligatures! \\='emacs-lisp-mode nil)
|
|
|
|
Note that this will keep all ligatures in `+ligatures-prog-mode-list' active, as
|
|
`emacs-lisp-mode' is derived from `prog-mode'."
|
|
(declare (indent defun))
|
|
(if (null ligatures)
|
|
(dolist (mode (ensure-list modes))
|
|
(add-to-list 'ligature-ignored-major-modes mode))
|
|
(after! ligature
|
|
(dolist (mode (ensure-list modes))
|
|
(setq ligature-ignored-major-modes (delq mode ligature-ignored-major-modes)))
|
|
(ligature-set-ligatures (ensure-list modes) font-ligatures))))
|