Major optimization refactor, across the board
+ enable lexical-scope everywhere (lexical-binding = t): ~5-10% faster startup; ~5-20% general boost + reduce consing, function calls & garbage collection by preferring cl-loop & dolist over lambda closures (for mapc[ar], add-hook, and various cl-lib filter/map/reduce functions) -- where possible + prefer functions with dedicated opcodes, like assq (see byte-defop's in bytecomp.el for more) + prefer pcase & cond (faster) over cl-case + general refactor for code readability + ensure naming & style conventions are adhered to + appease byte-compiler by marking unused variables with underscore + defer minor mode activation to after-init, emacs-startup or window-setup hooks; a customization opportunity for users + ensures custom functionality won't interfere with startup.
This commit is contained in:
parent
64a142b3fc
commit
c7254e7bdc
154 changed files with 1101 additions and 1118 deletions
|
@ -1,4 +1,4 @@
|
|||
;; core-ui.el --- draw me like one of your French editors
|
||||
;; core-ui.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar doom-ui-fringe-size '4 "Default fringe width")
|
||||
|
||||
|
@ -40,9 +40,6 @@
|
|||
|
||||
(fset #'yes-or-no-p #'y-or-n-p) ; y/n instead of yes/no
|
||||
|
||||
;; auto-enabled in Emacs 25+; I'd rather enable it manually
|
||||
(global-eldoc-mode -1)
|
||||
|
||||
;; show typed keystrokes in minibuffer
|
||||
(setq echo-keystrokes 0.02)
|
||||
;; ...but hide them while isearch is active
|
||||
|
@ -94,7 +91,7 @@ local value, whether or not it's permanent-local. Therefore, we cycle
|
|||
(setq show-paren-delay 0.1
|
||||
show-paren-highlight-openparen t
|
||||
show-paren-when-point-inside-paren t)
|
||||
(show-paren-mode +1)
|
||||
(add-hook 'window-setup-hook #'show-paren-mode)
|
||||
|
||||
;;; More reliable inter-window border
|
||||
;; The native border "consumes" a pixel of the fringe on righter-most splits,
|
||||
|
@ -102,7 +99,7 @@ local value, whether or not it's permanent-local. Therefore, we cycle
|
|||
(setq-default window-divider-default-places t
|
||||
window-divider-default-bottom-width 1
|
||||
window-divider-default-right-width 1)
|
||||
(window-divider-mode +1)
|
||||
(add-hook 'window-setup-hook #'window-divider-mode)
|
||||
|
||||
;; like diminish, but for major-modes. [pedantry intensifies]
|
||||
(defvar doom-ui-mode-names
|
||||
|
@ -122,13 +119,17 @@ mode is detected.")
|
|||
;; Bootstrap
|
||||
;;
|
||||
|
||||
;; auto-enabled in Emacs 25+; I'd rather enable it manually
|
||||
(global-eldoc-mode -1)
|
||||
|
||||
;; draw me like one of your French editors
|
||||
(tooltip-mode -1) ; relegate tooltips to echo area only
|
||||
(menu-bar-mode -1)
|
||||
(when (fboundp 'tool-bar-mode)
|
||||
(tool-bar-mode -1))
|
||||
(when (display-graphic-p)
|
||||
(scroll-bar-mode -1)
|
||||
;; buffer name in frame title
|
||||
;; buffer name in frame title
|
||||
(setq-default frame-title-format '("DOOM Emacs"))
|
||||
;; standardize fringe width
|
||||
(push (cons 'left-fringe doom-ui-fringe-size) default-frame-alist)
|
||||
|
@ -191,7 +192,7 @@ file."
|
|||
(set-buffer-modified-p nil))
|
||||
nil)
|
||||
|
||||
(add-hook! (highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||
(defun doom|init-highlight-indentation ()
|
||||
(if (or highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||
(progn
|
||||
(doom|inject-trailing-whitespace)
|
||||
|
@ -199,7 +200,9 @@ file."
|
|||
(add-hook 'after-save-hook #'doom|inject-trailing-whitespace nil t))
|
||||
(remove-hook 'before-save-hook #'delete-trailing-whitespace t)
|
||||
(remove-hook 'after-save-hook #'doom|inject-trailing-whitespace t)
|
||||
(delete-trailing-whitespace))))
|
||||
(delete-trailing-whitespace)))
|
||||
(add-hook! (highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||
#'doom|init-highlight-indentation))
|
||||
|
||||
;; For modes that don't adequately highlight numbers
|
||||
(def-package! highlight-numbers :commands highlight-numbers-mode)
|
||||
|
@ -265,8 +268,8 @@ file."
|
|||
;; indicators for empty lines past EOF
|
||||
(def-package! vi-tilde-fringe
|
||||
:when (display-graphic-p)
|
||||
:demand t
|
||||
:config (global-vi-tilde-fringe-mode t))
|
||||
:commands global-vi-tilde-fringe-mode
|
||||
:init (add-hook 'window-setup-hook #'global-vi-tilde-fringe-mode))
|
||||
|
||||
;; For a distractions-free-like UI, that dynamically resizes margets and can
|
||||
;; center a buffer.
|
||||
|
@ -292,12 +295,11 @@ file."
|
|||
(byte-compile #',sym))))))
|
||||
|
||||
(defsubst doom--prepare-modeline-segments (segments)
|
||||
(let (segs)
|
||||
(dolist (seg segments (nreverse segs))
|
||||
(push (if (stringp seg)
|
||||
seg
|
||||
(list (intern (format "doom-modeline-segment--%s" (symbol-name seg)))))
|
||||
segs))))
|
||||
(cl-loop for seg in segments
|
||||
if (stringp seg)
|
||||
collect seg
|
||||
else
|
||||
collect (list (intern (format "doom-modeline-segment--%s" (symbol-name seg))))))
|
||||
|
||||
(defmacro def-modeline! (name lhs &optional rhs)
|
||||
"Defines a modeline format and byte-compiles it. NAME is a symbol to identify
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue