2018-07-05 19:37:06 -07:00
|
|
|
;;; ui/pretty-code/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
(cond ((featurep! +fira)
|
|
|
|
(load! "+fira"))
|
|
|
|
((featurep! +iosevka)
|
2018-07-07 17:55:26 -04:00
|
|
|
(load! "+iosevka"))
|
|
|
|
((featurep! +pragmata-pro)
|
|
|
|
(load! "+pragmata-pro")))
|
2018-07-05 19:37:06 -07:00
|
|
|
|
2018-07-06 20:18:04 +02:00
|
|
|
(defvar +pretty-code-enabled-modes t
|
|
|
|
"List of major modes in which `prettify-symbols-mode' should be enabled.
|
|
|
|
If t, enable it everywhere. If the first element is 'not, enable it in any mode
|
|
|
|
besides what is listed.")
|
|
|
|
|
2018-07-05 19:37:06 -07:00
|
|
|
;; When you get to the right edge, it goes back to how it normally prints
|
|
|
|
(setq prettify-symbols-unprettify-at-point 'right-edge)
|
|
|
|
|
2018-07-06 20:18:04 +02:00
|
|
|
(defun +pretty-code|init-pretty-symbols ()
|
2018-07-08 13:43:18 +02:00
|
|
|
"Enable `prettify-symbols-mode'.
|
2018-07-06 20:18:04 +02:00
|
|
|
|
2018-07-08 13:43:18 +02:00
|
|
|
If in fundamental-mode, or a mode derived from special, comint, eshell or term
|
|
|
|
modes, this function does nothing.
|
|
|
|
|
|
|
|
Otherwise it builds `prettify-code-symbols-alist' according to
|
|
|
|
`+pretty-code-symbols-alist' for the current major-mode."
|
|
|
|
(unless (or (eq major-mode 'fundamental-mode)
|
2018-07-12 16:43:37 +02:00
|
|
|
(eq (get major-mode 'mode-class) 'special)
|
|
|
|
(derived-mode-p 'comint-mode 'eshell-mode 'term-mode))
|
2018-07-06 20:42:51 +02:00
|
|
|
(when (or (eq +pretty-code-enabled-modes t)
|
|
|
|
(if (eq (car +pretty-code-enabled-modes) 'not)
|
2018-07-06 20:18:04 +02:00
|
|
|
(not (memq major-mode (cdr +pretty-code-enabled-modes)))
|
|
|
|
(memq major-mode +pretty-code-enabled-modes)))
|
|
|
|
(setq prettify-symbols-alist
|
2018-07-06 20:42:51 +02:00
|
|
|
(append (cdr (assq major-mode +pretty-code-symbols-alist))
|
2018-07-06 20:18:04 +02:00
|
|
|
(default-value 'prettify-symbols-alist)))
|
|
|
|
(when prettify-symbols-mode
|
|
|
|
(prettify-symbols-mode -1))
|
|
|
|
(prettify-symbols-mode +1))))
|
|
|
|
|
|
|
|
(add-hook 'after-change-major-mode-hook #'+pretty-code|init-pretty-symbols)
|