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")) (load "autoloads"))
(message "Done!"))) (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. "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 (mapc (lambda (x) (set-fontset-font
t (cons x x) 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)) chars))
(defun doom-byte-compile (&optional minimal) (defun doom-byte-compile (&optional minimal)

View file

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

View file

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

View file

@ -42,5 +42,9 @@ gets killed.")
"A list of files that count as 'project files', which determine whether a "A list of files that count as 'project files', which determine whether a
folder is the root of a project or not.") 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) (provide 'core-vars)
;;; core-vars.el ends here ;;; core-vars.el ends here

View file

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