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 @@
|
|||
;;; ui/doom-modeline/config.el
|
||||
;;; ui/doom-modeline/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(eval-when-compile (require 'subr-x))
|
||||
|
||||
|
@ -90,6 +90,8 @@
|
|||
(defvar evil-state nil)
|
||||
(defvar evil-visual-selection nil)
|
||||
(defvar iedit-mode nil)
|
||||
(defvar all-the-icons-scale-factor)
|
||||
(defvar all-the-icons-default-adjust)
|
||||
|
||||
|
||||
;;
|
||||
|
@ -196,7 +198,6 @@ active."
|
|||
(propertize
|
||||
" " 'display
|
||||
(let ((data (make-list height (make-list width 1)))
|
||||
(i 0)
|
||||
(color (or color "None")))
|
||||
(create-image
|
||||
(concat
|
||||
|
@ -205,30 +206,26 @@ active."
|
|||
(length data)
|
||||
color
|
||||
color)
|
||||
(let ((len (length data))
|
||||
(idx 0))
|
||||
(apply #'concat
|
||||
(mapcar #'(lambda (dl)
|
||||
(setq idx (+ idx 1))
|
||||
(concat
|
||||
"\""
|
||||
(concat
|
||||
(mapcar #'(lambda (d)
|
||||
(if (eq d 0)
|
||||
(string-to-char " ")
|
||||
(string-to-char ".")))
|
||||
dl))
|
||||
(if (eq idx len) "\"};" "\",\n")))
|
||||
data))))
|
||||
(apply #'concat
|
||||
(cl-loop with idx = 0
|
||||
with len = (length data)
|
||||
for dl in data
|
||||
do (cl-incf idx)
|
||||
collect
|
||||
(concat "\""
|
||||
(cl-loop for d in dl
|
||||
if (= d 0) collect (string-to-char " ")
|
||||
else collect (string-to-char "."))
|
||||
(if (eq idx len) "\"};" "\",\n")))))
|
||||
'xpm t :ascent 'center)))))
|
||||
|
||||
(defun +doom-modeline--buffer-file ()
|
||||
(defsubst +doom-modeline--buffer-file ()
|
||||
"Display the base of the current buffer's filename."
|
||||
(if buffer-file-name
|
||||
(file-name-nondirectory (or buffer-file-truename (file-truename buffer-file-name)))
|
||||
"%b"))
|
||||
|
||||
(defun +doom-modeline--buffer-path ()
|
||||
(defsubst +doom-modeline--buffer-path ()
|
||||
"Displays the buffer's full path relative to the project root (includes the
|
||||
project root). Excludes the file basename. See `doom-buffer-name' for that."
|
||||
(when buffer-file-name
|
||||
|
@ -373,7 +370,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
+doom-modeline-vspc))))
|
||||
|
||||
;;
|
||||
(def-memoized! +doom-ml-icon (icon &optional text face)
|
||||
(defun +doom-ml-icon (icon &optional text face)
|
||||
"Displays an octicon ICON with FACE, followed by TEXT. Uses
|
||||
`all-the-icons-octicon' to fetch the icon."
|
||||
(concat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue