reverse => nreverse; other optimizations
This commit is contained in:
parent
4723a3d76f
commit
27cc4a9508
7 changed files with 22 additions and 22 deletions
|
@ -100,7 +100,7 @@ buffers. If there's nothing left, switch to `doom-fallback-buffer'. See
|
||||||
(let ((buffers (delq (current-buffer) (doom-real-buffers-list)))
|
(let ((buffers (delq (current-buffer) (doom-real-buffers-list)))
|
||||||
(project-dir (doom-project-root)))
|
(project-dir (doom-project-root)))
|
||||||
(cond ((or (not buffers)
|
(cond ((or (not buffers)
|
||||||
(zerop (mod n (1+ (length buffers)))))
|
(zerop (% n (1+ (length buffers)))))
|
||||||
(set-window-buffer nil (doom-fallback-buffer)))
|
(set-window-buffer nil (doom-fallback-buffer)))
|
||||||
((= (length buffers) 1)
|
((= (length buffers) 1)
|
||||||
(set-window-buffer nil (car buffers)))
|
(set-window-buffer nil (car buffers)))
|
||||||
|
|
|
@ -194,7 +194,7 @@ Example
|
||||||
desc nil)))
|
desc nil)))
|
||||||
|
|
||||||
(t (user-error "Invalid key %s" key))))
|
(t (user-error "Invalid key %s" key))))
|
||||||
`(progn ,@(reverse forms))))
|
`(progn ,@(nreverse forms))))
|
||||||
|
|
||||||
(provide 'core-keybinds)
|
(provide 'core-keybinds)
|
||||||
;;; core-keybinds.el ends here
|
;;; core-keybinds.el ends here
|
||||||
|
|
|
@ -111,7 +111,7 @@ Examples:
|
||||||
',(if quoted-p h (intern (format "%s-hook" h)))
|
',(if quoted-p h (intern (format "%s-hook" h)))
|
||||||
,fn ,append-p ,local-p)
|
,fn ,append-p ,local-p)
|
||||||
forms)))
|
forms)))
|
||||||
`(progn ,@(reverse forms)))))
|
`(progn ,@(nreverse forms)))))
|
||||||
|
|
||||||
(defmacro remove-hook! (&rest args)
|
(defmacro remove-hook! (&rest args)
|
||||||
"Convenience macro for `remove-hook'. Takes the same arguments as
|
"Convenience macro for `remove-hook'. Takes the same arguments as
|
||||||
|
|
|
@ -170,7 +170,7 @@ files."
|
||||||
(funcall load-fn (expand-file-name "init.el" doom-emacs-dir))
|
(funcall load-fn (expand-file-name "init.el" doom-emacs-dir))
|
||||||
(when load-p
|
(when load-p
|
||||||
(mapc (lambda (file) (funcall load-fn file t))
|
(mapc (lambda (file) (funcall load-fn file t))
|
||||||
(append (reverse (file-expand-wildcards (concat doom-core-dir "core*.el")))
|
(append (nreverse (file-expand-wildcards (concat doom-core-dir "core*.el")))
|
||||||
(file-expand-wildcards (concat doom-core-dir "autoload/*.el"))
|
(file-expand-wildcards (concat doom-core-dir "autoload/*.el"))
|
||||||
(doom--module-paths "config.el")))))
|
(doom--module-paths "config.el")))))
|
||||||
(when (or force-p (not doom-packages))
|
(when (or force-p (not doom-packages))
|
||||||
|
@ -227,17 +227,16 @@ is sorted by order of insertion."
|
||||||
(let (pairs)
|
(let (pairs)
|
||||||
(maphash (lambda (key value) (push (cons (car key) (cdr key)) pairs))
|
(maphash (lambda (key value) (push (cons (car key) (cdr key)) pairs))
|
||||||
doom-modules)
|
doom-modules)
|
||||||
(reverse pairs)))
|
(nreverse pairs)))
|
||||||
|
|
||||||
(defun doom--module-paths (&optional append-file)
|
(defun doom--module-paths (&optional append-file)
|
||||||
"Returns a list of absolute file paths to modules, with APPEND-FILE added, if
|
"Returns a list of absolute file paths to modules, with APPEND-FILE added, if
|
||||||
the file exists."
|
the file exists."
|
||||||
(let (paths)
|
(let (paths)
|
||||||
(dolist (pair (doom--module-pairs))
|
(dolist (pair (doom--module-pairs) (nreverse paths))
|
||||||
(let ((path (doom-module-path (car pair) (cdr pair) append-file)))
|
(let ((path (doom-module-path (car pair) (cdr pair) append-file)))
|
||||||
(when (file-exists-p path)
|
(when (file-exists-p path)
|
||||||
(push path paths))))
|
(push path paths))))))
|
||||||
(reverse paths)))
|
|
||||||
|
|
||||||
(defun doom--enable-module (module submodule &optional force-p)
|
(defun doom--enable-module (module submodule &optional force-p)
|
||||||
"Adds MODULE and SUBMODULE to `doom-modules', if it isn't already there (or if
|
"Adds MODULE and SUBMODULE to `doom-modules', if it isn't already there (or if
|
||||||
|
@ -268,8 +267,9 @@ byte-compilation."
|
||||||
(setq doom-modules ',doom-modules)
|
(setq doom-modules ',doom-modules)
|
||||||
|
|
||||||
(unless noninteractive
|
(unless noninteractive
|
||||||
,@(mapcar (lambda (module) `(require! ,(car module) ,(cdr module) t))
|
,@(let (forms)
|
||||||
(doom--module-pairs))
|
(dolist (module (doom--module-pairs) (nreverse forms))
|
||||||
|
(push `(require! ,(car module) ,(cdr module) t) forms)))
|
||||||
|
|
||||||
(when (display-graphic-p)
|
(when (display-graphic-p)
|
||||||
(require 'server)
|
(require 'server)
|
||||||
|
@ -349,7 +349,7 @@ them."
|
||||||
(pkg-pin (or (plist-get plist :pin)
|
(pkg-pin (or (plist-get plist :pin)
|
||||||
(and old-plist (plist-get old-plist :pin)))))
|
(and old-plist (plist-get old-plist :pin)))))
|
||||||
(when pkg-recipe
|
(when pkg-recipe
|
||||||
(when (= 0 (mod (length pkg-recipe) 2))
|
(when (= 0 (% (length pkg-recipe) 2))
|
||||||
(plist-put plist :recipe (cons name pkg-recipe)))
|
(plist-put plist :recipe (cons name pkg-recipe)))
|
||||||
(when pkg-pin
|
(when pkg-pin
|
||||||
(plist-put plist :pin nil)))
|
(plist-put plist :pin nil)))
|
||||||
|
@ -409,7 +409,7 @@ the commandline."
|
||||||
(when (file-exists-p generated-autoload-file)
|
(when (file-exists-p generated-autoload-file)
|
||||||
(delete-file generated-autoload-file)
|
(delete-file generated-autoload-file)
|
||||||
(message "Deleted old autoloads.el"))
|
(message "Deleted old autoloads.el"))
|
||||||
(dolist (file (reverse autoload-files))
|
(dolist (file (nreverse autoload-files))
|
||||||
(let ((inhibit-message t))
|
(let ((inhibit-message t))
|
||||||
(update-file-autoloads file))
|
(update-file-autoloads file))
|
||||||
(message "Scanned %s" (file-relative-name file doom-emacs-dir)))
|
(message "Scanned %s" (file-relative-name file doom-emacs-dir)))
|
||||||
|
@ -441,7 +441,7 @@ This may take a while."
|
||||||
(n 0)
|
(n 0)
|
||||||
results)
|
results)
|
||||||
(dolist (path (doom--module-paths))
|
(dolist (path (doom--module-paths))
|
||||||
(nconc targets (reverse (directory-files-recursively path "\\.el$"))))
|
(nconc targets (nreverse (directory-files-recursively path "\\.el$"))))
|
||||||
(dolist (file targets)
|
(dolist (file targets)
|
||||||
(push (cons (file-relative-name file doom-emacs-dir)
|
(push (cons (file-relative-name file doom-emacs-dir)
|
||||||
(and (byte-recompile-file file nil 0)
|
(and (byte-recompile-file file nil 0)
|
||||||
|
@ -451,7 +451,7 @@ This may take a while."
|
||||||
(if targets (message "\n"))
|
(if targets (message "\n"))
|
||||||
(message "Compiled %s files:\n%s" n
|
(message "Compiled %s files:\n%s" n
|
||||||
(mapconcat (lambda (file) (concat "+ " (if (cdr file) "SUCCESS" "FAIL") ": " (car file)))
|
(mapconcat (lambda (file) (concat "+ " (if (cdr file) "SUCCESS" "FAIL") ": " (car file)))
|
||||||
(reverse results) "\n")))))
|
(nreverse results) "\n")))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
(def-setting! :evil-state (&rest mode-state-list)
|
(def-setting! :evil-state (&rest mode-state-list)
|
||||||
"Set the initialize STATE of MODE using `evil-set-initial-state'."
|
"Set the initialize STATE of MODE using `evil-set-initial-state'."
|
||||||
(if (cl-every 'listp mode-state-list)
|
(if (cl-every 'listp mode-state-list)
|
||||||
(let (forms)
|
`(progn
|
||||||
(dolist (it mode-state-list)
|
,@(let (forms)
|
||||||
(unless (consp it)
|
(dolist (it mode-state-list (nreverse forms))
|
||||||
(error ":evil-state expected cons cells, got %s" it))
|
(unless (consp it)
|
||||||
(push `(evil-set-initial-state ',(car it) ',(cdr it)) forms))
|
(error ":evil-state expected cons cells, got %s" it))
|
||||||
`(progn ,@(reverse forms)))
|
(push `(evil-set-initial-state ',(car it) ',(cdr it)) forms))))
|
||||||
(let ((argc (length mode-state-list)))
|
(let ((argc (length mode-state-list)))
|
||||||
(unless (= argc 2)
|
(unless (= argc 2)
|
||||||
(error ":evil-state expected 2 arguments, got %s" argc)))
|
(error ":evil-state expected 2 arguments, got %s" argc)))
|
||||||
|
|
|
@ -299,7 +299,7 @@ end of the workspace list."
|
||||||
(defun +workspace/switch-to-last ()
|
(defun +workspace/switch-to-last ()
|
||||||
"Switch to the last workspace."
|
"Switch to the last workspace."
|
||||||
(interactive)
|
(interactive)
|
||||||
(+workspace/switch-to (car (reverse (+workspace-list)))))
|
(+workspace/switch-to (car (last (+workspace-list)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +workspace/cycle (n)
|
(defun +workspace/cycle (n)
|
||||||
|
|
|
@ -216,7 +216,7 @@ project root). Excludes the file basename. See `doom-buffer-name' for that."
|
||||||
(max-length (truncate (* (window-body-width) 0.4))))
|
(max-length (truncate (* (window-body-width) 0.4))))
|
||||||
(when (and buffer-path (not (equal buffer-path ".")))
|
(when (and buffer-path (not (equal buffer-path ".")))
|
||||||
(if (> (length buffer-path) max-length)
|
(if (> (length buffer-path) max-length)
|
||||||
(let ((path (reverse (split-string buffer-path "/" t)))
|
(let ((path (nreverse (split-string buffer-path "/" t)))
|
||||||
(output ""))
|
(output ""))
|
||||||
(when (and path (equal "" (car path)))
|
(when (and path (equal "" (car path)))
|
||||||
(setq path (cdr path)))
|
(setq path (cdr path)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue