refactor: minor refactors & nit picks across core

This commit is contained in:
Henrik Lissner 2021-10-09 19:55:47 +02:00
parent 432ca05c4f
commit f5c1332a31
6 changed files with 41 additions and 43 deletions

View file

@ -65,13 +65,6 @@ purpose.")
(require 'core-packages)
(doom-initialize-core-packages)
;; Don't generate superfluous files when writing temp buffers
(setq make-backup-files nil)
;; Stop user configuration from interfering with package management
(setq enable-dir-local-variables nil)
;; Reduce ambiguity, embrace specificity. It's more predictable.
(setq-default case-fold-search nil)
;; Default to using all cores, rather than half of them, since we compile things
;; ahead-of-time in a non-interactive session.
(defadvice! doom--comp-use-all-cores-a (&rest _)
@ -249,5 +242,15 @@ best to run Doom out of ~/.emacs.d and ~/.doom.d."
(maphash (doom-module-loader doom-cli-file) doom-modules)
(load! doom-cli-file doom-private-dir t)
;; Don't generate superfluous files when writing temp buffers
(setq make-backup-files nil)
;; Stop user configuration from interfering with package management
(setq enable-dir-local-variables nil)
;; Reduce ambiguity, embrace specificity. It's more predictable.
(setq-default case-fold-search nil)
;; Don't clog the user's trash with anything we clean up in this session.
(setq delete-by-moving-to-trash nil)
(provide 'core-cli)
;;; core-cli.el ends here

View file

@ -221,10 +221,10 @@ localleader prefix."
which-key-min-display-lines 6
which-key-side-window-slot -10)
:config
(defvar doom--initial-which-key-replacement-alist which-key-replacement-alist)
(put 'which-key-replacement-alist 'initial-value which-key-replacement-alist)
(add-hook! 'doom-before-reload-hook
(defun doom-reset-which-key-replacements-h ()
(setq which-key-replacement-alist doom--initial-which-key-replacement-alist)))
(setq which-key-replacement-alist (get 'which-key-replacement-alist 'initial-value))))
;; general improvements to which-key readability
(which-key-setup-side-window-bottom)
(setq-hook! 'which-key-init-buffer-hook line-spacing 3)

View file

@ -564,7 +564,6 @@ reverse this and trigger `after!' blocks at a more reasonable time."
;;; Hooks
(defvar doom--transient-counter 0)
(defmacro add-transient-hook! (hook-or-function &rest forms)
"Attaches a self-removing function to HOOK-OR-FUNCTION.
@ -577,7 +576,10 @@ advised)."
(let ((append (if (eq (car forms) :after) (pop forms)))
;; Avoid `make-symbol' and `gensym' here because an interned symbol is
;; easier to debug in backtraces (and is visible to `describe-function')
(fn (intern (format "doom--transient-%d-h" (cl-incf doom--transient-counter)))))
(fn (intern (format "doom--transient-%d-h"
(put 'add-transient-hook! 'counter
(1+ (or (get 'add-transient-hook! 'counter)
0)))))))
`(let ((sym ,hook-or-function))
(defun ,fn (&rest _)
,(format "Transient hook for %S" (doom-unquote hook-or-function))

View file

@ -53,20 +53,18 @@ uses a straight or package.el command directly).")
;;; package.el
;; Ensure that, if we do need package.el, it is configured correctly. You really
;; shouldn't be using it, but it may be convenient for quick package testing.
;; shouldn't be using it, but it may be convenient for quickly testing packages.
(setq package-enable-at-startup nil
package-user-dir (concat doom-local-dir "elpa/")
package-gnupghome-dir (expand-file-name "gpg" package-user-dir)
;; I omit Marmalade because its packages are manually submitted rather
;; than pulled, so packages are often out of date with upstream.
package-archives
(let ((proto (if gnutls-verify-error "https" "http")))
(list (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))
(cons "melpa" (concat proto "://melpa.org/packages/"))
(cons "org" (concat proto "://orgmode.org/elpa/")))))
package-gnupghome-dir (expand-file-name "gpg" package-user-dir))
;; package.el has no business modifying the user's init.el
(advice-add #'package--ensure-init-file :override #'ignore)
(after! package
(let ((s (if gnutls-verify-error "s" "")))
(prependq! package-archives
;; I omit Marmalade because its packages are manually submitted
;; rather than pulled, and so often out of date.
`(("melpa" . ,(format "http%s://melpa.org/packages/" s))
("org" . ,(format "http%s://orgmode.org/elpa/" s))))))
;; Refresh package.el the first time you call `package-install', so it can still
;; be used (e.g. to temporarily test packages). Remember to run 'doom sync' to
@ -564,10 +562,10 @@ Only use this macro in a module's (or your private) packages.el file."
This unpins packages, so that 'doom upgrade' downloads their latest version. It
can be used one of five ways:
+ To disable pinning wholesale: (unpin! t)
+ To unpin individual packages: (unpin! packageA packageB ...)
+ To unpin all packages in a group of modules: (unpin! :lang :tools ...)
+ To unpin packages in individual modules:
- To disable pinning wholesale: (unpin! t)
- To unpin individual packages: (unpin! packageA packageB ...)
- To unpin all packages in a group of modules: (unpin! :lang :tools ...)
- To unpin packages in individual modules:
(unpin! (:lang python javascript) (:tools docker))
Or any combination of the above.

View file

@ -94,19 +94,17 @@ debian, and derivatives). On most it's 'fd'.")
(setq compilation-buffer-name-function #'projectile-compilation-buffer-name
compilation-save-buffers-predicate #'projectile-current-project-buffer-p)
;; Override projectile's dirconfig file '.projectile' with doom's project marker '.project'.
;; Support the more generic .project files as an alternative to .projectile
(defadvice! doom--projectile-dirconfig-file-a ()
:override #'projectile-dirconfig-file
(cond
;; Prefers '.projectile' to maintain compatibility with existing projects.
((file-exists-p! (or ".projectile" ".project") (projectile-project-root)))
((expand-file-name ".project" (projectile-project-root)))))
(cond ((file-exists-p! (or ".projectile" ".project") (projectile-project-root)))
((expand-file-name ".project" (projectile-project-root)))))
;; Disable commands that won't work, as is, and that Doom already provides a
;; better alternative for.
(put 'projectile-ag 'disabled "Use +{ivy,helm}/project-search instead")
(put 'projectile-ripgrep 'disabled "Use +{ivy,helm}/project-search instead")
(put 'projectile-grep 'disabled "Use +{ivy,helm}/project-search instead")
(put 'projectile-ag 'disabled "Use +default/search-project instead")
(put 'projectile-ripgrep 'disabled "Use +default/search-project instead")
(put 'projectile-grep 'disabled "Use +default/search-project instead")
;; Treat current directory in dired as a "file in a project" and track it
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)

View file

@ -302,16 +302,14 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;; so these are just clutter (the scrollbar also impacts performance). Whats
;; more, the menu bar exposes functionality that Doom doesn't endorse.
;;
;; I am intentionally avoid using `menu-bar-mode', `tool-bar-mode', and
;; I am intentionally not calling `menu-bar-mode', `tool-bar-mode', and
;; `scroll-bar-mode' because they do extra and unnecessary work that can be more
;; concisely, and efficiently, expressed with these six lines:
;; concisely and efficiently expressed with these six lines:
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
;; These are disabled directly through their frame parameters to avoid the extra
;; work their minor modes do, but their variables must be unset too, otherwise
;; users will have to cycle them twice to re-enable them.
;; And set these to nil so users don't have to toggle the modes twice to
;; reactivate them.
(setq menu-bar-mode nil
tool-bar-mode nil
scroll-bar-mode nil)
@ -325,8 +323,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;; GUIs are inconsistent across systems and themes (and will rarely match our
;; active Emacs theme). They impose inconsistent shortcut key paradigms too.
;; It's best to avoid GUIs altogether and have Emacs handle the prompting, since
;; its promtps are governed by the same rules and keybinds as the rest of Emacs.
;; It's best to avoid them altogether and have Emacs handle the prompting.
(setq use-dialog-box nil)
(when (bound-and-true-p tooltip-mode)
(tooltip-mode -1))
@ -564,7 +561,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;;
;;; Theme & font
;; User themes should live in ~/.doom.d/themes, not ~/.emacs.d
;; User themes should live in $DOOMDIR/themes, not ~/.emacs.d
(setq custom-theme-directory (concat doom-private-dir "themes/"))
;; Always prioritize the user's themes above the built-in/packaged ones.