ui/pretty-code: minor reformatting

This commit is contained in:
Henrik Lissner 2019-10-28 21:44:42 -04:00
parent af69cd0840
commit 74d87a1e24
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 208 additions and 209 deletions

View file

@ -1,62 +1,10 @@
;;; ui/pretty-code/settings.el -*- lexical-binding: t; -*- ;;; ui/pretty-code/settings.el -*- lexical-binding: t; -*-
;;;###autoload
(defvar +pretty-code-symbols
'(;; org
:name "»"
:src_block "»"
:src_block_end "«"
;; Functional
:lambda "λ"
:def "ƒ"
:composition ""
:map ""
;; Types
:null ""
:true "𝕋"
:false "𝔽"
:int ""
:float ""
:str "𝕊"
:bool "𝔹"
;; Flow
:not ""
:in ""
:not-in ""
:and ""
:or ""
:for ""
:some ""
:return ""
:yield ""
;; Other
:tuple ""
:pipe "" ;; FIXME: find a non-private char
:dot "")
"Options plist for `set-pretty-symbols!'.
This should not contain any symbols from the Unicode Private Area! There is no
universal way of getting the correct symbol as that area varies from font to
font.")
;;;###autoload ;;;###autoload
(defvar +pretty-code-symbols-alist '((t)) (defvar +pretty-code-symbols-alist '((t))
"An alist containing a mapping of major modes to its value for "An alist containing a mapping of major modes to its value for
`prettify-symbols-alist'.") `prettify-symbols-alist'.")
;;;###autodef
(defun +pretty-code--correct-symbol-bounds (ligature-alist)
"Prepend non-breaking spaces to a ligature.
This way `compose-region' (called by `prettify-symbols-mode') will use the
correct width of the symbols instead of the width measured by `char-width'."
(let ((len (length (car ligature-alist)))
(acc (list (cdr ligature-alist))))
(while (> len 1)
(setq acc (cons #X00a0 (cons '(Br . Bl) acc))
len (1- len)))
(cons (car ligature-alist) acc)))
;;;###autodef ;;;###autodef
(defun set-pretty-symbols! (modes &rest plist) (defun set-pretty-symbols! (modes &rest plist)
"Associates string patterns with icons in certain major-modes. "Associates string patterns with icons in certain major-modes.

View file

@ -1,13 +1,54 @@
;;; ui/pretty-code/config.el -*- lexical-binding: t; -*- ;;; ui/pretty-code/config.el -*- lexical-binding: t; -*-
(cond ((featurep! +fira) (defvar +pretty-code-symbols
(load! "+fira")) '(;; org
((featurep! +iosevka) :name "»"
(load! "+iosevka")) :src_block "»"
((featurep! +hasklig) :src_block_end "«"
(load! "+hasklig")) ;; Functional
((featurep! +pragmata-pro) :lambda "λ"
(load! "+pragmata-pro"))) :def "ƒ"
:composition ""
:map ""
;; Types
:null ""
:true "𝕋"
:false "𝔽"
:int ""
:float ""
:str "𝕊"
:bool "𝔹"
;; Flow
:not ""
:in ""
:not-in ""
:and ""
:or ""
:for ""
:some ""
:return ""
:yield ""
;; Other
:tuple ""
:pipe "" ;; FIXME: find a non-private char
:dot "")
"Options plist for `set-pretty-symbols!'.
This should not contain any symbols from the Unicode Private Area! There is no
universal way of getting the correct symbol as that area varies from font to
font.")
(defun +pretty-code--correct-symbol-bounds (ligature-alist)
"Prepend non-breaking spaces to a ligature.
This way `compose-region' (called by `prettify-symbols-mode') will use the
correct width of the symbols instead of the width measured by `char-width'."
(let ((len (length (car ligature-alist)))
(acc (list (cdr ligature-alist))))
(while (> len 1)
(setq acc (cons #X00a0 (cons '(Br . Bl) acc))
len (1- len)))
(cons (car ligature-alist) acc)))
(defvar +pretty-code-enabled-modes t (defvar +pretty-code-enabled-modes t
"List of major modes in which `prettify-symbols-mode' should be enabled. "List of major modes in which `prettify-symbols-mode' should be enabled.
@ -40,3 +81,13 @@ Otherwise it builds `prettify-code-symbols-alist' according to
(prettify-symbols-mode +1)))) (prettify-symbols-mode +1))))
(add-hook 'after-change-major-mode-hook #'+pretty-code-init-pretty-symbols-h) (add-hook 'after-change-major-mode-hook #'+pretty-code-init-pretty-symbols-h)
;; Font-specific ligature support
(cond ((featurep! +fira)
(load! "+fira"))
((featurep! +iosevka)
(load! "+iosevka"))
((featurep! +hasklig)
(load! "+hasklig"))
((featurep! +pragmata-pro)
(load! "+pragmata-pro")))