Refactor doom-fix-unicode

This commit is contained in:
Henrik Lissner 2016-06-05 23:03:47 -04:00
parent c981b7fa5e
commit 2c44b65bc7
5 changed files with 42 additions and 21 deletions

View file

@ -322,13 +322,20 @@ Examples:
(load "autoloads"))
(message "Done!")))
(defun doom-fix-unicode (font chars &optional size)
(defun doom-fix-unicode (font &rest chars)
"Display certain unicode characters in a specific font.
e.g. (doom-fix-unicode \"DejaVu Sans\" '(?⚠ ?★ ?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓))"
e.g. (doom-fix-unicode \"DejaVu Sans\" ?⚠ ?★ )"
(declare (indent 1))
(mapc (lambda (x) (set-fontset-font
t (cons x x)
(font-spec :name font :size size)))
(cond ((fontp font)
font)
((listp font)
(font-spec :family (car font) :size (nth 1 font)))
((stringp font)
(font-spec :family font))
(t (error "FONT is an invalid type: %s" font)))))
chars))
(defun doom-byte-compile (&optional minimal)

View file

@ -343,7 +343,10 @@
"A-o" (kbd "ø")
"A-O" (kbd "Ø")
"A--" (kbd "")
"A-_" (kbd ""))
"A-_" (kbd "")
"A-8" (kbd "")
"A-*" (kbd "°")
"A-p" (kbd "π"))
(provide 'core-editor)
;;; core-editor.el ends here

View file

@ -65,9 +65,8 @@
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
(set-fringe-bitmap-face 'tilde 'fringe)
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
;; Fix certain unicode characters without upsetting line-height
(doom-fix-unicode "DejaVu Sans Mono" '(?★) 13)
(doom-fix-unicode "Hack" '() 13))
;; Fallback to `doom-unicode-font' for Unicode characters
(set-fontset-font t 'unicode doom-unicode-font))
;; Hide mode-line in help/compile window
(add-hook 'help-mode-hook 'doom|hide-mode-line)
@ -192,6 +191,13 @@
(defface mode-line-buffer-file nil "Face for mode-line buffer file name")
(defface mode-line-buffer-path nil "Face for mode-line buffer file path")
;; Make certain unicode glyphs bigger for UI purposes
(doom-fix-unicode '("DejaVu Sans Mono" 15) ?✱)
(let ((font "DejaVu Sans Mono for Powerline"))
(doom-fix-unicode (list font 10) ?)
(doom-fix-unicode (list font 16) ?∄)
(doom-fix-unicode (list font 15) ?))
;; Custom modeline segments
(spaceline-define-segment *buffer-path
(concat
@ -217,13 +223,13 @@
buffer-path))))
(if active 'mode-line-buffer-path)))
(powerline-raw "%b" (if active 'mode-line-buffer-file))
" "
(when buffer-file-name
(powerline-raw
(concat (when buffer-file-name
(concat
(if (buffer-modified-p) "")
(if (not (file-exists-p buffer-file-name)) "[!]")))
(if buffer-read-only "[RO]"))
(if (not (file-exists-p buffer-file-name)) ""
(if (buffer-modified-p) ""))
(if buffer-read-only ""))
'mode-line-is-modified)))
:tight-right t
:skip-alternate t)
@ -248,7 +254,8 @@
"Version control info"
(when vc-mode
(propertize
(concat "" (substring vc-mode (+ 2 (length (symbol-name (vc-backend buffer-file-name))))))
(concat ""
(substring vc-mode (+ 2 (length (symbol-name (vc-backend buffer-file-name))))))
'face (when active
(let ((state (vc-state buffer-file-name)))
(cond ((memq state '(edited added))
@ -378,11 +385,11 @@ anzu to be enabled."
(let ((fe (doom/-flycheck-count 'error))
(fw (doom/-flycheck-count 'warning)))
(concat
(if fe (propertize (format " %s " fe)
(if fe (propertize (format " %s " fe)
'face (if active
'doom-flycheck-error
'mode-line)))
(if fw (propertize (format " %s " fw)
(if fw (propertize (format " %s " fw)
'face (if active
'doom-flycheck-warning
'mode-line))))))))))

View file

@ -42,5 +42,9 @@ gets killed.")
"A list of files that count as 'project files', which determine whether a
folder is the root of a project or not.")
(defvar doom-unicode-font
(font-spec :family "DejaVu Sans Mono" :size 13)
"Font to fall back to for unicode glyphs.")
(provide 'core-vars)
;;; core-vars.el ends here

View file

@ -152,12 +152,12 @@
))
;; Display certain unicode characters properly
(doom-fix-unicode "DejaVu Sans" '(?⟳) 13)
(doom-fix-unicode "DejaVu Sans" '(?♭ ?♯))
(doom-fix-unicode "Hack" '(?× ?∙ ?⌉ ?⌈ ?⌊ ?⌋
?∩ ? ?⊆ ?⊂ ?⊄ ?⊇ ?⊃ ?⊅
?⇒ ?⇐ ?⇔ ?↔ ?→ ?≡ ?∴ ?∵ ?⊕ ?∀ ?∃ ?∄ ?∈ ?∉
? ?∧ ))
;; (doom-fix-unicode '("DejaVu Sans" 13)
;; ?♭ ?♯ ?⟳
;; ?× ?∙ ?÷ ?⌉ ?⌈ ?⌊ ?⌋
;; ?∩ ? ?⊆ ?⊂ ?⊄ ?⊇ ?⊃ ?⊅
;; ?⇒ ?⇐ ?⇔ ?↔ ?→ ?≡ ?∴ ?∵ ?⊕ ?∀ ?∃ ?∄ ?∈ ?∉
;; ? ?∧ ?¬)
(org-babel-do-load-languages
'org-babel-load-languages