Minor edits.

This commit is contained in:
Derek Taylor
2020-11-05 13:27:52 -06:00
parent 8fbacc6392
commit 35112d3f8c
170 changed files with 1304 additions and 756 deletions

View File

@@ -3,10 +3,6 @@
(defvar doom-bin-dir (concat doom-emacs-dir "bin/"))
(defvar doom-bin (concat doom-bin-dir "doom"))
;;;###autoload
(defvar doom-reload-hook nil
"A list of hooks to run when `doom/reload' is called.")
;;;###autoload
(defvar doom-reloading-p nil
"TODO")
@@ -76,7 +72,7 @@ This is experimental! It will try to do as `bin/doom sync' does, but from within
this Emacs session. i.e. it reload autoloads files (if necessary), reloads your
package list, and lastly, reloads your private config.el.
Runs `doom-reload-hook' afterwards."
Runs `doom-after-reload-hook' afterwards."
(interactive)
(require 'core-cli)
(when (and IS-WINDOWS (file-exists-p doom-env-file))
@@ -86,13 +82,14 @@ Runs `doom-reload-hook' afterwards."
(mapc #'require (cdr doom-incremental-packages))
(doom--if-compile (format "%s sync -e" doom-bin)
(let ((doom-reloading-p t))
(run-hook-wrapped 'doom-before-reload-hook #'doom-try-run-hook)
(doom-initialize 'force)
(with-demoted-errors "PRIVATE CONFIG ERROR: %s"
(general-auto-unbind-keys)
(unwind-protect
(doom-initialize-modules 'force)
(general-auto-unbind-keys t)))
(run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook)
(run-hook-wrapped 'doom-after-reload-hook #'doom-try-run-hook)
(message "Config successfully reloaded!"))
(user-error "Failed to reload your config")))

View File

@@ -12,7 +12,8 @@
init-file-debug
jka-compr-verbose
url-debug
use-package-verbose)
use-package-verbose
(message-log-max . 16384))
"A list of variable to toggle on `doom-debug-mode'.
Each entry can be a variable symbol or a cons cell whose CAR is the variable
@@ -49,8 +50,9 @@ symbol and CDR is the value to set it to when `doom-debug-mode' is activated.")
((if (boundp var)
(set-default var enabled)
(add-to-list 'doom--debug-vars-undefined var)))))
(when (fboundp 'explain-pause-mode)
(explain-pause-mode enabled))
(when (called-interactively-p 'any)
(when (fboundp 'explain-pause-mode)
(explain-pause-mode (if enabled +1 -1))))
;; Watch for changes in `doom-debug-variables', or when packages load (and
;; potentially define one of `doom-debug-variables'), in case some of them
;; aren't defined when `doom-debug-mode' is first loaded.
@@ -211,16 +213,12 @@ branch and commit."
;;;###autoload
(defun doom/info (&optional raw)
"Collects some debug information about your Emacs session, formats it into
markdown and copies it to your clipboard, ready to be pasted into bug reports!"
"Collects some debug information about your Emacs session, formats it and
copies it to your clipboard, ready to be pasted into bug reports!"
(interactive "P")
(let ((buffer (get-buffer-create "*doom-info*"))
(let ((buffer (get-buffer-create "*doom info*"))
(info (doom-info)))
(with-current-buffer buffer
(or (not doom-interactive-p)
(eq major-mode 'markdown-mode)
(not (fboundp 'markdown-mode))
(markdown-mode))
(erase-buffer)
(if raw
(progn
@@ -234,7 +232,7 @@ markdown and copies it to your clipboard, ready to be pasted into bug reports!"
(let ((sexp (prin1-to-string (sexp-at-point))))
(delete-region beg end)
(insert sexp))))))
(insert "<details>\n\n```\n")
(insert "```\n")
(dolist (group info)
(insert! "%-8s%-10s %s\n"
((upcase (symbol-name (car group)))
@@ -243,12 +241,12 @@ markdown and copies it to your clipboard, ready to be pasted into bug reports!"
(dolist (spec (cddr group))
(insert! (indent 8 "%-10s %s\n")
((car spec) (cdr spec)))))
(insert "```\n</details>"))
(insert "```\n"))
(if (not doom-interactive-p)
(print! (buffer-string))
(switch-to-buffer buffer)
(pop-to-buffer buffer)
(kill-new (buffer-string))
(print! (green "Copied markdown to clipboard"))))))
(print! (green "Copied your doom info to clipboard"))))))
;;;###autoload
(defun doom/am-i-secure ()
@@ -316,14 +314,20 @@ Some items are not supported by the `nsm.el' module."
(with-temp-file file
(prin1 `(progn
(setq noninteractive nil
user-init-file ,file
process-environment ',doom--initial-process-environment
exec-path ',doom--initial-exec-path
init-file-debug t
doom--initial-load-path load-path
load-path ',load-path
package--init-file-ensured t
package-user-dir ,package-user-dir
package-archives ',package-archives
user-emacs-directory ,doom-emacs-dir)
user-emacs-directory ,doom-emacs-dir
comp-deferred-compilation nil
comp-eln-load-path ',(bound-and-true-p comp-eln-load-path)
comp-async-env-modifier-form ',(bound-and-true-p comp-async-env-modifier-form)
comp-deferred-compilation-black-list ',(bound-and-true-p comp-deferred-compilation-black-list))
(with-eval-after-load 'undo-tree
;; undo-tree throws errors because `buffer-undo-tree' isn't
;; correctly initialized
@@ -446,6 +450,21 @@ will be automatically appended to the result."
(interactive)
(browse-url "https://github.com/hlissner/doom-emacs/issues/new/choose"))
;;;###autoload
(defun doom/copy-buffer-contents (buffer-name)
"Copy the contents of BUFFER-NAME to your clipboard."
(interactive
(list (if current-prefix-arg
(completing-read "Select buffer: " (mapcar #'buffer-name (buffer-list)))
(buffer-name (current-buffer)))))
(let ((buffer (get-buffer buffer-name)))
(unless (buffer-live-p buffer)
(user-error "Buffer isn't live"))
(kill-new
(with-current-buffer buffer
(substring-no-properties (buffer-string))))
(message "Contents of %S were copied to the clipboard" buffer-name)))
;;
;;; Profiling

View File

@@ -245,7 +245,7 @@ If FORCE-P, delete without confirmation."
(user-error "Aborted"))
(let ((buf (current-buffer)))
(unwind-protect
(progn (delete-file path) t)
(progn (delete-file path t) t)
(if (file-exists-p path)
(error "Failed to delete %S" short-path)
;; Ensures that windows displaying this buffer will be switched to

View File

@@ -662,6 +662,7 @@ Uses the symbol at point or the current selection, if available."
(doom--help-search
(cl-loop for (file . _) in (cl-remove-if-not #'stringp load-history :key #'car)
for filebase = (file-name-sans-extension file)
if (file-exists-p! (format "%s.el" filebase))
if (file-exists-p! (or (format "%s.el.gz" filebase)
(format "%s.el" filebase)))
collect it)
query "Search loaded files: "))

View File

@@ -98,8 +98,8 @@ If DIR is not a project, it will be indexed (but not cached)."
(error "Directory %S does not exist" dir))
(unless (file-readable-p dir)
(error "Directory %S isn't readable" dir))
(let* ((default-directory (file-truename (expand-file-name dir)))
(projectile-project-root (doom-project-root default-directory))
(let* ((default-directory (file-truename dir))
(projectile-project-root (doom-project-root dir))
(projectile-enable-caching projectile-enable-caching))
(cond ((and projectile-project-root (file-equal-p projectile-project-root default-directory))
(unless (doom-project-p default-directory)
@@ -116,8 +116,8 @@ If DIR is not a project, it will be indexed (but not cached)."
#'projectile-find-file)))
((fboundp 'counsel-file-jump) ; ivy only
(call-interactively #'counsel-file-jump))
((project-current)
(project-find-file-in nil (list default-directory) nil))
((project-current nil dir)
(project-find-file-in nil nil dir))
((fboundp 'helm-find-files)
(call-interactively #'helm-find-files))
((call-interactively #'find-file)))))

View File

@@ -172,7 +172,9 @@ windows (unlike `doom/window-maximize-buffer'). Activate again to undo."
(let* ((window (selected-window))
(dedicated-p (window-dedicated-p window))
(preserved-p (window-parameter window 'window-preserved-size))
(ignore-window-parameters t))
(ignore-window-parameters t)
(window-resize-pixelwise nil)
(frame-resize-pixelwise nil))
(unwind-protect
(progn
(when dedicated-p

View File

@@ -10,6 +10,7 @@ one wants that.")
(defvar doom-autoloads-cached-vars
'(doom-modules
doom-disabled-packages
comp-deferred-compilation-black-list
load-path
auto-mode-alist
interpreter-mode-alist
@@ -34,16 +35,13 @@ one wants that.")
(and (print! (start "Generating autoloads file..."))
(doom-autoloads--write
file
`((unless (equal emacs-major-version ,emacs-major-version)
(signal 'doom-error
(list "The installed version of Emacs has changed since last 'doom sync' ran"
"Run 'doom sync && doom build' to bring Doom up to speed")))
(unless (equal doom-version ,doom-version)
`((unless (equal doom-version ,doom-version)
(signal 'doom-error
(list "The installed version of Doom has changed since last 'doom sync' ran"
"Run 'doom sync' to bring Doom up to speed"))))
(mapcar (lambda (var) `(set ',var ',(symbol-value var)))
doom-autoloads-cached-vars)
(cl-loop for var in doom-autoloads-cached-vars
when (boundp var)
collect `(set ',var ',(symbol-value var)))
(doom-autoloads--scan
(append (cl-loop for dir
in (append (list doom-core-dir)

View File

@@ -15,10 +15,10 @@
(insert (json-encode (doom-info)))
(json-pretty-print-buffer)
(print! (buffer-string))))
("--md"
(doom/info))
((or `nil "--lisp")
("--lisp"
(doom/info 'raw))
(`nil
(doom/info))
(_
(user-error "I don't understand %S. Did you mean --json, --md/--markdown or --lisp?"
format)))

View File

@@ -128,8 +128,8 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
(remq nil (append blacklist doom-env-blacklist)))
(if (not (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "=")))
(remq nil (append whitelist doom-env-whitelist))))
(print! (info "Ignoring %s") env)
(print! (info "Whitelisted %s") env)
(print! (debug "Ignoring %s") env)
(print! (debug "Whitelisted %s") env)
(insert env "\0\n"))
(insert env "\0\n")))
(print! (success "Successfully generated %S")

View File

@@ -28,6 +28,12 @@ DOOMDIR environment variable. e.g.
;; Create `doom-private-dir'
(if noconfig-p
(print! (warn "Not copying private config template, as requested"))
;; Create DOOMDIR in ~/.config/doom if ~/.config/emacs exists.
(when (and (not (file-directory-p doom-private-dir))
(not (getenv "DOOMDIR")))
(let ((xdg-config-dir (or (getenv "XDG_CONFIG_HOME") "~/.config")))
(when (file-in-directory-p doom-emacs-dir xdg-config-dir)
(setq doom-private-dir (expand-file-name "doom/" xdg-config-dir)))))
(print! (start "Creating %s") (relpath doom-private-dir))
(make-directory doom-private-dir 'parents)
(print-group!

View File

@@ -61,10 +61,15 @@ list remains lean."
(if full commit (substring commit 0 7)))
(defun doom--commit-log-between (start-ref end-ref)
(and (straight--call
"git" "log" "--oneline" "--no-merges"
"-n" "25" end-ref (concat "^" (regexp-quote start-ref)))
(straight--process-get-output)))
(when-let*
((status (straight--call
"git" "log" "--oneline" "--no-merges"
"-n" "26" end-ref (concat "^" (regexp-quote start-ref))))
(output (string-trim-right (straight--process-get-output)))
(lines (split-string output "\n")))
(if (> (length lines) 25)
(concat (string-join (butlast lines 1) "\n") "\n[...]")
output)))
(defun doom--barf-if-incomplete-packages ()
(let ((straight-safe-mode t))
@@ -115,9 +120,34 @@ list remains lean."
(setq straight--recipe-lookup-cache (make-hash-table :test #'eq)
doom--cli-updated-recipes t)))
(defvar doom--expected-eln-files nil)
(defvar doom--eln-output-expected nil)
(defvar doom--eln-output-path (car (bound-and-true-p comp-eln-load-path)))
(defun doom--eln-file-name (file)
"Return the short .eln file name corresponding to `file'."
(concat comp-native-version-dir "/"
(file-name-nondirectory
(comp-el-to-eln-filename file))))
(defun doom--eln-output-file (eln-name)
"Return the expected .eln file corresponding to `eln-name'."
(concat doom--eln-output-path eln-name))
(defun doom--eln-error-file (eln-name)
"Return the expected .error file corresponding to `eln-name'."
(concat doom--eln-output-path eln-name ".error"))
(defun doom--find-eln-file (eln-name)
"Find `eln-name' on the `comp-eln-load-path'."
(cl-some (lambda (eln-path)
(let ((file (concat eln-path eln-name)))
(when (file-exists-p file)
file)))
comp-eln-load-path))
(defun doom--elc-file-outdated-p (file)
"Check whether the corresponding .elc for `file' is outdated."
(let ((elc-file (byte-compile-dest-file file)))
;; NOTE Ignore missing elc files, they could be missing due to
;; `no-byte-compile'. Rebuilding unnecessarily is expensive.
@@ -126,17 +156,12 @@ list remains lean."
(doom-log "%s is newer than %s" file elc-file)
t)))
;; DEPRECATED Remove later
(defun doom--comp-output-filename (file)
(if (fboundp 'comp-output-filename)
(comp-output-filename file)
(comp-el-to-eln-filename file)))
(defun doom--eln-file-outdated-p (file)
(when-let* ((eln-file (doom--comp-output-filename file))
(error-file (concat eln-file ".error")))
(push eln-file doom--expected-eln-files)
(cond ((file-exists-p eln-file)
"Check whether the corresponding .eln for `file' is outdated."
(let* ((eln-name (doom--eln-file-name file))
(eln-file (doom--find-eln-file eln-name))
(error-file (doom--eln-error-file eln-name)))
(cond (eln-file
(when (file-newer-than-file-p file eln-file)
(doom-log "%s is newer than %s" file eln-file)
t))
@@ -145,18 +170,20 @@ list remains lean."
(doom-log "%s is newer than %s" file error-file)
t))
(t
(doom-log "%s doesn't exist" eln-file)
(doom-log "%s doesn't exist" eln-name)
t))))
(defun doom--native-compile-done-h (file)
(when-let* ((file)
(eln-file (doom--comp-output-filename file))
(error-file (concat eln-file ".error")))
(if (file-exists-p eln-file)
(doom-log "Compiled %s" eln-file)
(make-directory (file-name-directory error-file) 'parents)
(write-region "" nil error-file)
(doom-log "Compiled %s" error-file))))
"Callback fired when an item has finished async compilation."
(when file
(let* ((eln-name (doom--eln-file-name file))
(eln-file (doom--eln-output-file eln-name))
(error-file (doom--eln-error-file eln-name)))
(if (file-exists-p eln-file)
(doom-log "Compiled %s" eln-file)
(make-directory (file-name-directory error-file) 'parents)
(write-region "" nil error-file)
(doom-log "Wrote %s" error-file)))))
(defun doom--native-compile-jobs ()
"How many async native compilation jobs are queued or in-progress."
@@ -169,25 +196,39 @@ list remains lean."
(defun doom--wait-for-compile-jobs ()
"Wait for all pending async native compilation jobs."
(cl-loop for pending = (doom--native-compile-jobs)
for tick = 0 then (% (1+ tick) 15)
with previous = 0
while (not (zerop pending))
if (and (zerop tick) (/= previous pending)) do
(print! "- Waiting for %d async jobs..." pending)
if (/= previous pending) do
(print! (info "\033[KWaiting for %d async jobs...\033[1A" pending))
(setq previous pending)
else do
(let ((inhibit-message t))
(sleep-for 0.1)))
;; HACK Write .error files for any missing files which still don't exist.
;; We'll just assume there was some kind of error...
(cl-loop for eln-file in doom--expected-eln-files
for error-file = (concat eln-file ".error")
(sleep-for 0.1))))
(defun doom--write-missing-eln-errors ()
"Write .error files for any expected .eln files that are missing."
(cl-loop for file in doom--eln-output-expected
for eln-name = (doom--eln-file-name file)
for eln-file = (doom--eln-output-file eln-name)
for error-file = (doom--eln-error-file eln-name)
unless (or (file-exists-p eln-file)
(file-exists-p error-file)) do
(make-directory (file-name-directory error-file) 'parents)
(write-region "" nil error-file)
(doom-log "Compiled %s" error-file))
(setq doom--expected-eln-files nil))
(file-newer-than-file-p error-file file))
do (make-directory (file-name-directory error-file) 'parents)
(write-region "" nil error-file)
(doom-log "Wrote %s" error-file))
(setq doom--eln-output-expected nil))
(defun doom--compile-site-packages ()
"Queue async compilation for all non-doom Elisp files."
(when (fboundp 'native-compile-async)
(cl-loop with paths = (cl-loop for path in load-path
unless (string-prefix-p doom-local-dir path)
collect path)
for file in (doom-files-in paths :match "\\.el\\(?:\\.gz\\)?$")
if (and (file-exists-p (byte-compile-dest-file file))
(not (doom--find-eln-file (doom--eln-file-name file)))) do
(doom-log "Compiling %s" file)
(native-compile-async file nil 'late))))
(defun doom-cli-packages-install ()
@@ -209,7 +250,7 @@ declaration) or dependency thereof that hasn't already been."
(let ((straight-use-package-pre-build-functions
(cons (lambda (pkg &rest _)
(when-let (commit (cdr (assoc pkg pinned)))
(print! (info "Checked out %s") commit)))
(print! (info "Checked out %s: %s") pkg commit)))
straight-use-package-pre-build-functions)))
(straight-use-package (intern package))
;; HACK Line encoding issues can plague repos with dirty
@@ -224,7 +265,9 @@ declaration) or dependency thereof that hasn't already been."
(error
(signal 'doom-package-error (list package e))))))
(progn
(doom--compile-site-packages)
(doom--wait-for-compile-jobs)
(doom--write-missing-eln-errors)
(print! (success "Installed %d packages") (length built)))
(print! (info "No packages need to be installed"))
nil))))
@@ -267,12 +310,16 @@ declaration) or dependency thereof that hasn't already been."
if (or (if want-byte (doom--elc-file-outdated-p file))
(if want-native (doom--eln-file-outdated-p file)))
do (setq outdated t)
(when want-native
(push file doom--eln-output-expected))
finally return outdated))
(puthash package t straight--packages-to-rebuild))))
(straight-use-package (intern package))))
(progn
(doom--compile-site-packages)
(doom--wait-for-compile-jobs)
(print! (success "Rebuilt %d package(s)") (length built)))
(doom--write-missing-eln-errors)
(print! (success "\033[KRebuilt %d package(s)") (length built)))
(print! (success "No packages need rebuilding"))
nil))))
@@ -359,13 +406,12 @@ declaration) or dependency thereof that hasn't already been."
(cl-return)))
(puthash local-repo t repos-to-rebuild)
(puthash package t packages-to-rebuild)
(unless (string-empty-p output)
(print! (start "\033[K(%d/%d) Updating %s...") i total local-repo)
(print-group! (print! "%s" (indent 2 output))))
(print! (success "\033[K(%d/%d) %s updated (%s -> %s)")
i total local-repo
(doom--abbrev-commit ref)
(doom--abbrev-commit target-ref)))
(doom--abbrev-commit target-ref))
(unless (string-empty-p output)
(print-group! (print! "%s" (indent 2 output)))))
(user-error
(signal 'user-error (error-message-string e)))
(error
@@ -490,9 +536,10 @@ If ELPA-P, include packages installed with package.el (M-x package-install)."
(and (or repos-p regraft-repos-p)
(straight--directory-files (straight--repos-dir) nil nil 'sort))))
(list (when builds-p
(seq-filter #'file-directory-p
(seq-remove (doom-rpartial #'gethash straight--profile-cache)
(straight--directory-files (straight--build-dir) nil nil 'sort))))
(let ((default-directory (straight--build-dir)))
(seq-filter #'file-directory-p
(seq-remove (doom-rpartial #'gethash straight--profile-cache)
(straight--directory-files default-directory nil nil 'sort)))))
(when repos-p
(seq-remove (doom-rpartial #'straight--checkhash straight--repo-cache)
rdirs))

View File

@@ -11,8 +11,7 @@ following shell commands:
cd ~/.emacs.d
git pull --rebase
bin/doom clean
bin/doom sync
bin/doom update"
bin/doom sync -u"
:bare t
(let ((doom-auto-discard force-p))
(cond
@@ -100,13 +99,15 @@ following shell commands:
(cdr (doom-call-process "git" "log" "-1" "--format=%cr" "HEAD"))
(substring new-rev 0 10)
(cdr (doom-call-process "git" "log" "-1" "--format=%cr" target-remote))))
(when (and (not auto-accept-p)
(y-or-n-p "View the comparison diff in your browser?"))
(print! (info "Opened github in your browser."))
(browse-url (format "https://github.com/hlissner/doom-emacs/compare/%s...%s"
this-rev
new-rev)))
(let ((diff-url
(format "https://github.com/hlissner/doom-emacs/compare/%s...%s"
this-rev
new-rev)))
(print! "Link to diff: %s" diff-url)
(when (and (not auto-accept-p)
(y-or-n-p "View the comparison diff in your browser?"))
(print! (info "Opened github in your browser."))
(browse-url diff-url)))
(if (not (or auto-accept-p
(y-or-n-p "Proceed with upgrade?")))

View File

@@ -441,7 +441,12 @@ everywhere we use it (and internally)."
Includes package management, diagnostics, unit tests, and byte-compilation.
This tool also makes it trivial to launch Emacs out of a different folder or
with a different private module."
with a different private module.
Environment variables:
EMACSDIR Where to find the Doom Emacs repo (normally ~/.emacs.d)
DOOMDIR Where to find your private Doom config (normally ~/.doom.d)
DOOMLOCALDIR Where to store local files (normally ~/.emacs.d/.local)"
(condition-case e
(with-output-to! doom-cli-log-file
(catch 'exit

View File

@@ -31,30 +31,30 @@ These thresholds are in MB, and is used by `doom--optimize-for-large-files-a'.")
;;
;;; File handling
(defadvice! doom--optimize-for-large-files-a (orig-fn &rest args)
"Set `doom-large-file-p' if the file is too large.
(defadvice! doom--prepare-for-large-files-a (size _ filename &rest _)
"Sets `doom-large-file-p' if the file is considered large.
Uses `doom-large-file-size-alist' to determine when a file is too large. When
`doom-large-file-p' is set, other plugins can detect this and reduce their
runtime costs (or disable themselves) to ensure the buffer is as fast as
possible."
:around #'after-find-file
(if (setq doom-large-file-p
(and buffer-file-name
(not doom-large-file-p)
(file-exists-p buffer-file-name)
(ignore-errors
(> (nth 7 (file-attributes buffer-file-name))
(* 1024 1024
(assoc-default buffer-file-name doom-large-file-size-alist
#'string-match-p))))))
(prog1 (apply orig-fn args)
(if (memq major-mode doom-large-file-excluded-modes)
(setq doom-large-file-p nil)
(when (fboundp 'so-long-minor-mode) ; in case the user disabled it
(so-long-minor-mode +1))
(message "Large file detected! Cutting a few corners to improve performance...")))
(apply orig-fn args)))
:before #'abort-if-file-too-large
(and (numberp size)
(> size
(* 1024 1024
(assoc-default filename doom-large-file-size-alist
#'string-match-p)))
(setq doom-large-file-p size)))
(defadvice! doom--optimize-for-large-files-a (&rest _)
"Trigger `so-long-minor-mode' if the file is large."
:after #'after-find-file
(when (and doom-large-file-p buffer-file-name)
(if (memq major-mode doom-large-file-excluded-modes)
(setq doom-large-file-p nil)
(when (fboundp 'so-long-minor-mode) ; in case the user disabled it
(so-long-minor-mode +1))
(message "Large file detected! Cutting a few corners to improve performance..."))))
;; Resolve symlinks when opening files, so that any operations are conducted
;; from the file's true directory (like `find-file').
@@ -78,22 +78,35 @@ possible."
(progn (make-directory parent-directory 'parents)
t))))))
;; Don't autosave files or create lock/history/backup files. We don't want
;; copies of potentially sensitive material floating around or polluting our
;; filesystem. We rely on git and our own good fortune instead. Fingers crossed!
(setq auto-save-default nil
create-lockfiles nil
;; Don't generate backups or lockfiles. While auto-save maintains a copy so long
;; as a buffer is unsaved, backups create copies once, when the file is first
;; written, and never again until it is killed and reopened. This is better
;; suited to version control, and I don't want world-readable copies of
;; potentially sensitive material floating around our filesystem.
(setq create-lockfiles nil
make-backup-files nil
;; But have a place to store them in case we do use them...
;; auto-save-list-file-name (concat doom-cache-dir "autosave")
auto-save-list-file-prefix (concat doom-cache-dir "autosave/")
auto-save-file-name-transforms `((".*" ,auto-save-list-file-prefix t))
backup-directory-alist `((".*" . ,(concat doom-cache-dir "backup/"))))
;; But in case the user does enable it, some sensible defaults:
version-control t ; number each backup file
backup-by-copying t ; instead of renaming current file (clobbers links)
delete-old-versions t ; clean up after itself
kept-old-versions 5
kept-new-versions 5
backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/"))))
(after! tramp
;; Backing up files on remotes can be incredibly slow and prone to a variety
;; of IO errors. Better to disable it altogether in tramp buffers:
(add-to-list 'backup-directory-alist (cons tramp-file-name-regexp nil)))
;; But turn on auto-save, so we have a fallback in case of crashes or lost data.
;; Use `recover-file' or `recover-session' to recover them.
(setq auto-save-default t
;; Don't auto-disable auto-save after deleting big chunks. This defeats
;; the purpose of a failsafe. This adds the risk of losing the data we
;; just deleted, but I believe that's VCS's jurisdiction, not ours.
auto-save-include-big-deletions t
;; ...but have directories set up in case we use it.
auto-save-list-file-prefix (concat doom-cache-dir "autosave/")
auto-save-file-name-transforms
(list (list "\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
;; Prefix tramp autosaves to prevent conflicts with local ones
(concat auto-save-list-file-prefix "tramp-\\2") t)
(list ".*" auto-save-list-file-prefix t)))
(add-hook! 'after-save-hook
(defun doom-guess-mode-h ()
@@ -565,7 +578,13 @@ files, so we replace calls to `pp' with the much faster `prin1'."
(use-package! ws-butler
;; a less intrusive `delete-trailing-whitespaces' on save
:hook (doom-first-buffer . ws-butler-global-mode))
:hook (doom-first-buffer . ws-butler-global-mode)
:config
;; ws-butler normally preserves whitespace in the buffer (but strips it from
;; the written file). While sometimes convenient, this behavior is not
;; intuitive. To the average user it looks like whitespace cleanup is failing,
;; which causes folks to redundantly install their own.
(setq ws-butler-keep-whitespace-before-point nil))
(provide 'core-editor)
;;; core-editor.el ends here

View File

@@ -26,15 +26,18 @@ and Emacs states, and for non-evil users.")
;;
;;; Keybind settings
(cond (IS-MAC
(setq mac-command-modifier 'super
mac-option-modifier 'meta
ns-command-modifier 'super
ns-option-modifier 'meta
ns-right-option-modifier 'none))
(IS-WINDOWS
(setq w32-lwindow-modifier 'super
w32-rwindow-modifier 'super)))
(cond
(IS-MAC
(setq mac-command-modifier 'super
ns-command-modifier 'super
mac-option-modifier 'meta
ns-option-modifier 'meta
;; Free up the right option for character composition
mac-right-option-modifier 'none
ns-right-option-modifier 'none))
(IS-WINDOWS
(setq w32-lwindow-modifier 'super
w32-rwindow-modifier 'super)))
;;
@@ -184,15 +187,18 @@ localleader prefix."
(use-package! which-key
:hook (doom-first-input . which-key-mode)
:init
(setq which-key-sort-order #'which-key-prefix-then-key-order
(setq which-key-sort-order #'which-key-key-order-alpha
which-key-sort-uppercase-first nil
which-key-add-column-padding 1
which-key-max-display-columns nil
which-key-min-display-lines 6
which-key-side-window-slot -10)
:config
(defvar doom--initial-which-key-replacement-alist 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)))
;; general improvements to which-key readability
(set-face-attribute 'which-key-local-map-description-face nil :weight 'bold)
(which-key-setup-side-window-bottom)
(setq-hook! 'which-key-init-buffer-hook line-spacing 3)
@@ -309,7 +315,7 @@ For example, :nvi will map to (list 'normal 'visual 'insert). See
(let ((a (plist-get doom--map-parent-state prop))
(b (plist-get doom--map-state prop)))
(if (and a b)
`(general--concat nil ,a ,b)
`(general--concat t ,a ,b)
(or a b))))
(defun doom--map-nested (wrapper rest)

View File

@@ -492,8 +492,9 @@ advised)."
`(let ((fn (intern (format "%s-h" ,hook-var))))
(fset
fn (lambda (&rest _)
(run-hook-wrapped ,hook-var #'doom-try-run-hook)
(set ,hook-var nil)))
(when after-init-time
(run-hook-wrapped ,hook-var #'doom-try-run-hook)
(set ,hook-var nil))))
(put ,hook-var 'permanent-local t)
(dolist (on (list ,@targets))
(if (functionp on)
@@ -671,5 +672,27 @@ set earlier in the setq-local. The return value of the
(setq pairs (cdr (cdr pairs))))
(macroexp-progn (nreverse expr)))))
(eval-when! (version< emacs-version "27.1")
;; DEPRECATED Backported from Emacs 27; earlier verisons don't have REMOTE arg
(defun executable-find (command &optional remote)
"Search for COMMAND in `exec-path' and return the absolute file name.
Return nil if COMMAND is not found anywhere in `exec-path'. If
REMOTE is non-nil, search on the remote host indicated by
`default-directory' instead."
(if (and remote (file-remote-p default-directory))
(let ((res (locate-file
command
(mapcar
(lambda (x) (concat (file-remote-p default-directory) x))
(exec-path))
exec-suffixes 'file-executable-p)))
(when (stringp res) (file-local-name res)))
;; Use 1 rather than file-executable-p to better match the
;; behavior of call-process.
(let ((default-directory
(let (file-name-handler-alist)
(file-name-quote default-directory))))
(locate-file command exec-path exec-suffixes 1)))))
(provide 'core-lib)
;;; core-lib.el ends here

View File

@@ -249,8 +249,9 @@ those directories. The first returned path is always `doom-private-dir'."
:type 'dirs
:mindepth 1
:depth 1)))
(cl-loop for plist being the hash-values of doom-modules
collect (plist-get plist :path)))
(delq
nil (cl-loop for plist being the hash-values of doom-modules
collect (plist-get plist :path)) ))
nil))
(defun doom-module-mplist-map (fn mplist)

View File

@@ -79,6 +79,10 @@ uses a straight or package.el command directly).")
(setq straight-base-dir doom-local-dir
straight-repository-branch "develop"
;; Since byte-code is rarely compatible across different versions of
;; Emacs, it's best we build them in separate directories, per emacs
;; version.
straight-build-dir (format "build-%s" emacs-version)
straight-cache-autoloads nil ; we already do this, and better.
;; Doom doesn't encourage you to modify packages in place. Disabling this
;; makes 'doom sync' instant (once everything set up), which is much nicer
@@ -474,8 +478,9 @@ elsewhere."
(when-let (recipe (plist-get plist :recipe))
(cl-destructuring-bind
(&key local-repo _files _flavor
_no-build _no-byte-compile _no-native-compile _no-autoloads
_type _repo _host _branch _remote _nonrecursive _fork _depth)
_no-build _build _post-build _no-byte-compile
_no-native-compile _no-autoloads _type _repo _host _branch
_remote _nonrecursive _fork _depth)
recipe
;; Expand :local-repo from current directory
(when local-repo

View File

@@ -166,29 +166,23 @@ And if it's a function, evaluate it."
projectile-indexing-method 'hybrid
projectile-generic-command
(lambda (_)
(let ((find-exe-fn
(if EMACS27+
(doom-rpartial #'executable-find t)
#'executable-find)))
;; If fd exists, use it for git and generic projects. fd is a rust
;; program that is significantly faster than git ls-files or find, and
;; it respects .gitignore. This is recommended in the projectile docs.
(cond
((when-let
(bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if find-exe-fn (list "fdfind" "fd"))
doom-projectile-fd-binary))
(concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow"
bin)
(if IS-WINDOWS " --path-separator=/"))))
;; Otherwise, resort to ripgrep, which is also faster than find
((funcall find-exe-fn "rg")
(concat "rg -0 --files --follow --color=never --hidden"
(cl-loop for dir in projectile-globally-ignored-directories
concat " --glob "
concat (shell-quote-argument (concat "!" dir)))
(if IS-WINDOWS " --path-separator /")))
("find . -type f -print0")))))
;; If fd exists, use it for git and generic projects. fd is a rust
;; program that is significantly faster than git ls-files or find, and
;; it respects .gitignore. This is recommended in the projectile docs.
(cond
((when-let
(bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if (doom-rpartial #'executable-find t)
(list "fdfind" "fd"))
doom-projectile-fd-binary))
(concat (format "%s . -0 -H --color=never --type file --type symlink --follow"
bin)
(if IS-WINDOWS " --path-separator=/"))))
;; Otherwise, resort to ripgrep, which is also faster than find
((executable-find "rg" t)
(concat "rg -0 --files --follow --color=never --hidden"
(if IS-WINDOWS " --path-separator /")))
("find . -type f -print0"))))
(defadvice! doom--projectile-default-generic-command-a (orig-fn &rest args)
"If projectile can't tell what kind of project you're in, it issues an error

View File

@@ -9,7 +9,7 @@
(defvar doom-theme nil
"A symbol representing the Emacs theme to load at startup.
This is changed by `load-theme'.")
Set to `default' to load no theme at all. This is changed by `load-theme'.")
(defvar doom-font nil
"The default font to use.
@@ -402,11 +402,16 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;; serve much purpose when the selection is so much more visible.
(defvar doom--hl-line-mode nil)
(add-hook! 'hl-line-mode-hook
(defun doom-truly-disable-hl-line-h ()
(unless hl-line-mode
(setq-local doom--hl-line-mode nil))))
(add-hook! '(evil-visual-state-entry-hook activate-mark-hook)
(defun doom-disable-hl-line-h ()
(when hl-line-mode
(setq-local doom--hl-line-mode t)
(hl-line-mode -1))))
(hl-line-mode -1)
(setq-local doom--hl-line-mode t))))
(add-hook! '(evil-visual-state-exit-hook deactivate-mark-hook)
(defun doom-enable-hl-line-maybe-h ()
@@ -516,6 +521,12 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(add-hook! '(prog-mode-hook text-mode-hook conf-mode-hook)
#'display-line-numbers-mode)
;; Fix #2742: cursor is off by 4 characters in `artist-mode'
;; REVIEW Reported upstream https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43811
;; DEPRECATED Fixed in Emacs 28; remove when we drop 27 support
(unless EMACS28+
(add-hook 'artist-mode-hook #'doom-disable-line-numbers-h))
;;
;;; Theme & font
@@ -570,7 +581,9 @@ behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.")
(defun doom-init-theme-h (&optional frame)
"Load the theme specified by `doom-theme' in FRAME."
(when (and doom-theme (not (memq doom-theme custom-enabled-themes)))
(when (and doom-theme
(not (eq doom-theme 'default))
(not (memq doom-theme custom-enabled-themes)))
(with-selected-frame (or frame (selected-frame))
(let ((doom--prefer-theme-elc t)) ; DEPRECATED in Emacs 27
(load-theme doom-theme t)))))

View File

@@ -1,5 +1,10 @@
;;; core.el --- the heart of the beast -*- lexical-binding: t; -*-
;; Prevent unwanted runtime builds in gccemacs (native-comp); packages are
;; compiled ahead-of-time when they are installed and site files are compiled
;; when gccemacs is installed.
(setq comp-deferred-compilation nil)
(eval-when-compile
(when (< emacs-major-version 26)
(error "Detected Emacs v%s. Doom only supports Emacs 26 and newer"
@@ -34,7 +39,7 @@
;; path/io functions. You get a minor speed up by nooping this. However, this
;; may cause problems on builds of Emacs where its site lisp files aren't
;; byte-compiled and we're forced to load the *.el.gz files (e.g. on Alpine)
(unless noninteractive
(unless (or noninteractive (daemonp))
(defvar doom--initial-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
@@ -96,6 +101,7 @@ envvar will enable this at startup.")
"Root directory for local storage.
Use this as a storage location for this system's installation of Doom Emacs.
These files should not be shared across systems. By default, it is used by
`doom-etc-dir' and `doom-cache-dir'. Must end with a slash.")
@@ -127,7 +133,8 @@ Use this for files that change often, like cache files. Must end with a slash.")
Defaults to ~/.config/doom, ~/.doom.d or the value of the DOOMDIR envvar;
whichever is found first. Must end in a slash.")
(defconst doom-autoloads-file (concat doom-local-dir "autoloads.el")
(defconst doom-autoloads-file
(concat doom-local-dir "autoloads." emacs-version ".el")
"Where `doom-reload-core-autoloads' stores its core autoloads.
This file is responsible for informing Emacs where to find all of Doom's
@@ -154,7 +161,7 @@ users).")
;;; Emacs core configuration
;; lo', longer logs ahoy, so to reliably locate lapses in doom's logic later
(setq message-log-max 8192)
(setq message-log-max 4096)
;; Reduce debug output, well, unless we've asked for it.
(setq debug-on-error doom-debug-p
@@ -279,15 +286,10 @@ config.el instead."
(add-to-list 'comp-eln-load-path (concat doom-cache-dir "eln/")))
(after! comp
;; HACK `comp-eln-load-path' isn't fully respected yet, because native
;; compilation occurs in another emacs process that isn't seeded with our
;; value for `comp-eln-load-path', so we inject it ourselves:
(setq comp-async-env-modifier-form
`(progn
,comp-async-env-modifier-form
(setq comp-eln-load-path ',(bound-and-true-p comp-eln-load-path))))
;; HACK Disable native-compilation for some troublesome packages
(add-to-list 'comp-deferred-compilation-black-list "/evil-collection-vterm\\.el\\'"))
(dolist (entry (list (concat "\\`" (regexp-quote doom-local-dir) ".*/evil-collection-vterm\\.el\\'")
(concat "\\`" (regexp-quote doom-autoloads-file) "'")))
(add-to-list 'comp-deferred-compilation-black-list entry)))
;;
@@ -472,6 +474,12 @@ If this is a daemon session, load them all immediately instead."
(defvar doom-first-buffer-hook nil
"Transient hooks run before the first interactively opened buffer.")
(defvar doom-after-reload-hook nil
"A list of hooks to run before `doom/reload' has reloaded Doom.")
(defvar doom-before-reload-hook nil
"A list of hooks to run after `doom/reload' has reloaded Doom.")
;;
;;; Bootstrap helpers
@@ -565,16 +573,17 @@ to least)."
(with-eval-after-load 'package (require 'core-packages))
(with-eval-after-load 'straight (doom-initialize-packages))
;; Bootstrap our GC manager
(add-hook 'doom-first-input-hook #'gcmh-mode)
;; Bootstrap the interactive session
(add-hook! 'window-setup-hook
(add-hook 'hack-local-variables-hook #'doom-run-local-var-hooks-h)
(add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-maybe-h 'append)
(add-hook 'doom-first-input-hook #'gcmh-mode)
(add-hook-trigger! 'doom-first-input-hook 'pre-command-hook)
(add-hook-trigger! 'doom-first-file-hook 'after-find-file 'dired-initial-position-hook)
(add-hook-trigger! 'doom-first-buffer-hook 'after-find-file 'doom-switch-buffer-hook))
(add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-maybe-h)
(add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h)
(add-hook 'window-setup-hook #'doom-display-benchmark-h 'append)
(add-hook 'hack-local-variables-hook #'doom-run-local-var-hooks-h)
(add-hook 'window-setup-hook #'doom-display-benchmark-h)
(add-hook-trigger! 'doom-first-buffer-hook 'after-find-file 'doom-switch-buffer-hook)
(add-hook-trigger! 'doom-first-file-hook 'after-find-file 'dired-initial-position-hook)
(add-hook-trigger! 'doom-first-input-hook 'pre-command-hook)
(if doom-debug-p (doom-debug-mode +1))
;; Load core/core-*.el, the user's private init.el, then their config.el

View File

@@ -3,7 +3,7 @@
;; core.el
(package! auto-minor-mode :pin "17cfa1b54800fdef2975c0c0531dad34846a5065")
(package! gcmh :pin "b1bde5089169a74f62033d027e06e98cbeedd43f")
(package! gcmh :pin "84c43a4c0b41a595ac6e299fa317d2831813e580")
(package! explain-pause-mode
:recipe (:host github
:repo "lastquestion/explain-pause-mode")
@@ -16,9 +16,8 @@
:repo "raxod502/straight.el"
:branch ,straight-repository-branch
:local-repo "straight.el"
:files ("straight*.el")
:no-build t)
:pin "0c7c7571349b628d87acde474a754f05e86ca876")
:files ("straight*.el"))
:pin "728ea18ea590fcd8fb48f5bed30e135942d97221")
;; core-modules.el
(package! use-package
@@ -26,18 +25,18 @@
:pin "4fb1f9a68f1e7e7d614652afc017a6652fd029f1")
;; core-ui.el
(package! all-the-icons :pin "8c0228053dd6693d926970d89270094be52b0f75")
(package! all-the-icons :pin "6917b08f64dd8487e23769433d6cb9ba11f4152f")
(package! hide-mode-line :pin "88888825b5b27b300683e662fa3be88d954b1cea")
(package! highlight-numbers :pin "8b4744c7f46c72b1d3d599d4fb75ef8183dee307")
(package! rainbow-delimiters :pin "5125f4e47604ad36c3eb4706310fcafac729ca8c")
(package! rainbow-delimiters :pin "f43d48a24602be3ec899345a3326ed0247b960c6")
(package! restart-emacs :pin "9aa90d3df9e08bc420e1c9845ee3ff568e911bd9")
;; core-editor.el
(package! better-jumper :pin "6d240032ca213ccb3347e25f26c29b6822bf03a7")
(package! better-jumper :pin "fe548d22c9228b60d9c8a2a452a6c2e03dfdf238")
(package! dtrt-indent :pin "50c440c80e0d15303d8ab543bce4c56e9c2bf407")
(package! helpful :pin "c0662aa07266fe204f4e6d72ccaa6af089400556")
(package! helpful :pin "1671e1dd08ca9543bf80e878135c6bbba84efe05")
(package! pcre2el :pin "0b5b2a2c173aab3fd14aac6cf5e90ad3bf58fa7d")
(package! smartparens :pin "555626a43f9bb1985aa9a0eb675f2b88b29702c8")
(package! smartparens :pin "c59bfef7e8f1687ac77b0afaaaed86d8051d3de1")
(package! so-long
:built-in 'prefer ; included in Emacs 27+
;; REVIEW so-long is slated to be published to ELPA eventually, but until then
@@ -52,8 +51,8 @@
:pin "2bb49d3ee7d2cba133bc7e9cdac416cd1c5e4fe0")
;; core-projects.el
(package! projectile :pin "46d2010c6a6cccfc4be72317f10ea99fd041ab54")
(package! projectile :pin "3670ebea092c7bae4973f5bcecf5ac3588a0ac60")
;; core-keybinds.el
(package! general :pin "a0b17d207badf462311b2eef7c065b884462cb7c")
(package! which-key :pin "e48e190a75a0c176e1deac218b891e77792d6921")
(package! which-key :pin "ae59b7edb0d82aa0251803fdfbde6b865083c8b8")