ui/pretty-code: general refactor & fix premature )

This commit is contained in:
Henrik Lissner 2018-07-06 20:18:04 +02:00
parent 2a125000ae
commit fc87a72904
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
5 changed files with 153 additions and 151 deletions

View file

@ -5,7 +5,31 @@
((featurep! +iosevka)
(load! "+iosevka")))
(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.")
;; When you get to the right edge, it goes back to how it normally prints
(setq prettify-symbols-unprettify-at-point 'right-edge)
(add-hook! 'after-change-major-mode-hook #'+pretty-code|init-pretty-symbols)
(defun +pretty-code|init-pretty-symbols ()
"Enabled `prettify-symbols-mode'.
If the current major mode is disabled in `+pretty-code-enabled-modes', this
function does nothing. Otherwise, it sets the value of
`prettify-code-symbols-alist' according to `+pretty-code-symbols-alist' for the
current major mode."
(unless (eq major-mode 'fundamental-mode)
(when (or (eq +pretty-code-enabled-modes 't)
(if (eq (car +pretty-code-enabled-modes 'not))
(not (memq major-mode (cdr +pretty-code-enabled-modes)))
(memq major-mode +pretty-code-enabled-modes)))
(setq prettify-symbols-alist
(append (alist-get major-mode +pretty-code-symbols-alist)
(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)