diff --git a/bin/doom b/bin/doom index 6ce7dc813..15ca6aaf2 100755 --- a/bin/doom +++ b/bin/doom @@ -31,7 +31,7 @@ (defcli! :main ((help-p ["-h" "--help"] "Same as help command") - (debug-p ["-d" "--debug"] "Turns on doom-debug-mode (and debug-on-error)") + (debug-p ["-d" "--debug"] "Turns on doom-debug-p (and debug-on-error)") (yes-p ["-y" "--yes"] "Auto-accept all confirmation prompts") (emacsdir ["--emacsdir" dir] "Use the emacs config at DIR (e.g. ~/.emacs.d)") (doomdir ["--doomdir" dir] "Use the private module at DIR (e.g. ~/.doom.d)") @@ -55,7 +55,7 @@ with a different private module." (print! (info "DOOMLOCALDIR=%s") localdir)) (when debug-p (setenv "DEBUG" "1") - (setq doom-debug-mode t) + (setq doom-debug-p t) (print! (info "Debug mode on"))) (when yes-p (setenv "YES" "1") diff --git a/core/autoload/debug.el b/core/autoload/debug.el index ed1683be7..aaf7f008d 100644 --- a/core/autoload/debug.el +++ b/core/autoload/debug.el @@ -5,7 +5,7 @@ ;;;###autoload (defvar doom-debug-variables - '(doom-debug-mode + '(doom-debug-p init-file-debug debug-on-error garbage-collection-messages @@ -18,9 +18,10 @@ "A list of variable to toggle on `doom/toggle-debug-mode'.") ;;;###autoload -(defun doom/toggle-debug-mode (&optional arg) - "Toggle `debug-on-error' and `doom-debug-mode' for verbose logging." - (interactive (list (or current-prefix-arg 'toggle))) +(define-minor-mode doom-debug-mode + "Toggle `debug-on-error' and `doom-debug-p' for verbose logging." + :init-value doom-debug-p + :global t (let ((value (cond ((eq arg 'toggle) (not doom-debug-mode)) ((> (prefix-numeric-value arg) 0))))) @@ -77,7 +78,7 @@ ready to be pasted in a bug report on github." (features ,@system-configuration-features) (build . ,(format-time-string "%b %d, %Y" emacs-build-time)) (buildopts ,system-configuration-options) - (windowsys . ,(if noninteractive 'batch window-system)) + (windowsys . ,(if doom-interactive-p window-system 'batch)) (daemonp . ,(cond ((daemonp) 'daemon) ((and (require 'server) (server-running-p)) @@ -171,10 +172,10 @@ markdown and copies it to your clipboard, ready to be pasted into bug reports!" (let ((buffer (get-buffer-create "*doom-info*")) (info (doom-info))) (with-current-buffer buffer - (unless (or noninteractive - (eq major-mode 'markdown-mode) - (not (fboundp 'markdown-mode))) - (markdown-mode)) + (or (not doom-interactive-p) + (eq major-mode 'markdown-mode) + (not (fboundp 'markdown-mode)) + (markdown-mode)) (erase-buffer) (if raw (progn @@ -198,7 +199,7 @@ markdown and copies it to your clipboard, ready to be pasted into bug reports!" (insert! (indent 8 "%-10s %s\n") ((car spec) (cdr spec))))) (insert "```\n")) - (if noninteractive + (if (not doom-interactive-p) (print! (buffer-string)) (switch-to-buffer buffer) (kill-new (buffer-string)) diff --git a/core/autoload/scratch.el b/core/autoload/scratch.el index 31a95ec96..645d26e68 100644 --- a/core/autoload/scratch.el +++ b/core/autoload/scratch.el @@ -111,7 +111,7 @@ the first, fresh scratch buffer you create. This accepts: (remove-hook 'doom-switch-buffer-hook #'doom-persist-scratch-buffers-after-switch-h))) ;;;###autoload -(unless noninteractive +(when doom-interactive-p (add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h)) diff --git a/core/cli/autoloads.el b/core/cli/autoloads.el index 8150513c3..09e161919 100644 --- a/core/cli/autoloads.el +++ b/core/cli/autoloads.el @@ -91,10 +91,10 @@ one wants that.") (defun doom-cli--byte-compile-file (file) (condition-case-unless-debug e - (let ((byte-compile-warnings (if doom-debug-mode byte-compile-warnings)) + (let ((byte-compile-warnings (if doom-debug-p byte-compile-warnings)) (byte-compile-dynamic-docstrings t)) (when (byte-compile-file file) - (unless doom-interactive-mode + (unless doom-interactive-p (add-hook 'doom-cli-post-success-execute-hook #'doom-cli--warn-refresh-session-h)) (load (byte-compile-dest-file file) nil t))) (error diff --git a/core/cli/byte-compile.el b/core/cli/byte-compile.el index 2f55f2b48..9b8ccd356 100644 --- a/core/cli/byte-compile.el +++ b/core/cli/byte-compile.el @@ -92,7 +92,7 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files." ;; fully loaded. Which usually aren't so in an noninteractive session. (let ((load-prefer-newer t) (noninteractive t) - doom-interactive-mode) + doom-interactive-p) (doom-initialize 'force) (quiet! (doom-initialize-packages)))) @@ -180,7 +180,7 @@ module. This does not include your byte-compiled, third party packages.'" (print-group! (cl-loop with default-directory = doom-emacs-dir with success = 0 - with esc = (if doom-debug-mode "" "\033[1A") + with esc = (if doom-debug-p "" "\033[1A") for path in (append (doom-glob doom-emacs-dir "*.elc") (doom-files-in doom-private-dir :match "\\.elc$" :depth 1) diff --git a/core/cli/doctor.el b/core/cli/doctor.el index 3d708368d..b2636a121 100644 --- a/core/cli/doctor.el +++ b/core/cli/doctor.el @@ -79,7 +79,7 @@ in." (print! (start "Checking Doom Emacs...")) (condition-case-unless-debug ex (print-group! - (let ((doom-interactive-mode 'doctor)) + (let ((doom-interactive-p 'doctor)) (doom-initialize 'force) (doom-initialize-modules)) diff --git a/core/cli/env.el b/core/cli/env.el index b9090617b..a46d760b0 100644 --- a/core/cli/env.el +++ b/core/cli/env.el @@ -95,7 +95,7 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in "Generating") (path env-file)) (print-group! - (when doom-interactive-mode + (when doom-interactive-p (user-error "'doom env' must be run on the command line, not an interactive session")) (goto-char (point-min)) (insert diff --git a/core/cli/packages.el b/core/cli/packages.el index a6c7ec4e5..dd15c4d12 100644 --- a/core/cli/packages.el +++ b/core/cli/packages.el @@ -106,7 +106,7 @@ list remains lean." nil (mapcar (doom-rpartial #'gethash straight--repo-cache) (mapcar #'symbol-name straight-recipe-repositories))) (recipe package type local-repo) - (let ((esc (unless doom-debug-mode "\033[1A")) + (let ((esc (unless doom-debug-p "\033[1A")) (ref (straight-vc-get-commit type local-repo)) newref output) (print! (start "\033[KUpdating recipes for %s...%s") package esc) @@ -207,7 +207,7 @@ declaration) or dependency thereof that hasn't already been." (packages-to-rebuild (make-hash-table :test 'equal)) (repos-to-rebuild (make-hash-table :test 'equal)) (total (length recipes)) - (esc (unless doom-debug-mode "\033[1A")) + (esc (unless doom-debug-p "\033[1A")) (i 0) errors) (when recipes diff --git a/core/core-cli.el b/core/core-cli.el index 13c988519..5f4c9c532 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -257,7 +257,7 @@ original state.") (defadvice! doom--straight-fallback-to-y-or-n-prompt-a (orig-fn &optional prompt) :around #'straight-are-you-sure (or doom-auto-accept - (if doom-interactive-mode + (if doom-interactive-p (funcall orig-fn prompt) (y-or-n-p (format! "%s" (or prompt "")))))) @@ -269,7 +269,7 @@ original state.") (defadvice! doom--straight-fallback-to-tty-prompt-a (orig-fn prompt actions) "Modifies straight to prompt on the terminal when in noninteractive sessions." :around #'straight--popup-raw - (if doom-interactive-mode + (if doom-interactive-p (funcall orig-fn prompt actions) (let ((doom--straight-discard-options doom--straight-discard-options)) ;; We can't intercept C-g, so no point displaying any options for this key diff --git a/core/core-editor.el b/core/core-editor.el index 165dd5d48..b58bedaac 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -359,7 +359,7 @@ files, so we replace calls to `pp' with the much faster `prin1'." (use-package! dtrt-indent ;; Automatic detection of indent settings - :when doom-interactive-mode + :when doom-interactive-p :hook ((change-major-mode-after-body read-only-mode) . doom-detect-indentation-h) :config (defun doom-detect-indentation-h () @@ -369,7 +369,7 @@ files, so we replace calls to `pp' with the much faster `prin1'." (memq major-mode doom-detect-indentation-excluded-modes) (member (substring (buffer-name) 0 1) '(" " "*"))) ;; Don't display messages in the echo area, but still log them - (let ((inhibit-message (not doom-debug-mode))) + (let ((inhibit-message (not doom-debug-p))) (dtrt-indent-mode +1)))) ;; Enable dtrt-indent even in smie modes so that it can update `tab-width', diff --git a/core/core-lib.el b/core/core-lib.el index 75e90e060..1f44c06ff 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -66,10 +66,10 @@ list is returned as-is." (substring (symbol-name keyword) 1)) (defmacro doom-log (format-string &rest args) - "Log to *Messages* if `doom-debug-mode' is on. + "Log to *Messages* if `doom-debug-p' is on. Does not interrupt the minibuffer if it is in use, but still logs to *Messages*. Accepts the same arguments as `message'." - `(when doom-debug-mode + `(when doom-debug-p (let ((inhibit-message (active-minibuffer-window))) (message ,(concat (propertize "DOOM " 'face 'font-lock-comment-face) @@ -231,9 +231,9 @@ the same name, for use with `funcall' or `apply'. ARGLIST and BODY are as in This silences calls to `message', `load', `write-region' and anything that writes to `standard-output'." - `(if doom-debug-mode + `(if doom-debug-p (progn ,@forms) - ,(if doom-interactive-mode + ,(if doom-interactive-p `(let ((inhibit-message t) (save-silently t)) (prog1 ,@forms (message ""))) diff --git a/core/core-modules.el b/core/core-modules.el index db7104c25..43be58de2 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -258,10 +258,10 @@ This value is cached. If REFRESH-P, then don't use the cached value." (eval-and-compile (autoload 'use-package "use-package-core" nil nil t) - (setq use-package-compute-statistics doom-debug-mode - use-package-verbose doom-debug-mode - use-package-minimum-reported-time (if doom-debug-mode 0 0.1) - use-package-expand-minimally doom-interactive-mode)) + (setq use-package-compute-statistics doom-debug-p + use-package-verbose doom-debug-p + use-package-minimum-reported-time (if doom-debug-p 0 0.1) + use-package-expand-minimally doom-interactive-p)) (defvar doom--deferred-packages-alist '(t)) diff --git a/core/core-packages.el b/core/core-packages.el index a7870f0ed..a9f244689 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -110,7 +110,7 @@ package's name as a symbol, and whose CDR is the plist supplied to its "://github.com/" (or (plist-get recipe :repo) "raxod502/straight.el"))) (branch (or (plist-get recipe :branch) straight-repository-branch)) - (call (if doom-debug-mode #'doom-exec-process #'doom-call-process))) + (call (if doom-debug-p #'doom-exec-process #'doom-call-process))) (if (not (file-directory-p repo-dir)) (message "Installing straight...") ;; TODO Rethink this clumsy workaround diff --git a/core/core-projects.el b/core/core-projects.el index d1a840b9b..627b66c0c 100644 --- a/core/core-projects.el +++ b/core/core-projects.el @@ -26,7 +26,7 @@ Emacs.") projectile-locate-dominating-file) :init (setq projectile-cache-file (concat doom-cache-dir "projectile.cache") - projectile-enable-caching doom-interactive-mode + projectile-enable-caching doom-interactive-p projectile-globally-ignored-files '(".DS_Store" "Icon " "TAGS") projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o") projectile-kill-buffers-filter 'kill-only-files @@ -112,7 +112,7 @@ b) represent blacklisted directories that are too big, change too often or are private. (see `doom-projectile-cache-blacklist'), c) are not valid projectile projects." (when (and (bound-and-true-p projectile-projects-cache) - doom-interactive-mode) + doom-interactive-p) (cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist) for proot in (hash-table-keys projectile-projects-cache) if (or (not (stringp proot)) diff --git a/core/core.el b/core/core.el index 95045b529..aa910d235 100644 --- a/core/core.el +++ b/core/core.el @@ -63,13 +63,13 @@ (defvar doom-init-time nil "The time it took, in seconds, for Doom Emacs to initialize.") -(defvar doom-debug-mode (or (getenv "DEBUG") init-file-debug) +(defvar doom-debug-p (or (getenv "DEBUG") init-file-debug) "If non-nil, Doom will log more. Use `doom/toggle-debug-mode' to toggle it. The --debug-init flag and setting the DEBUG envvar will enable this at startup.") -(defvar doom-interactive-mode (not noninteractive) +(defvar doom-interactive-p (not noninteractive) "If non-nil, Emacs is in interactive mode.") ;;; Directories/files @@ -157,8 +157,8 @@ users).") (setq message-log-max 8192) ;; Reduce debug output, well, unless we've asked for it. -(setq debug-on-error doom-debug-mode - jka-compr-verbose doom-debug-mode) +(setq debug-on-error doom-debug-p + jka-compr-verbose doom-debug-p) ;; Contrary to what many Emacs users have in their configs, you really don't ;; need more than this to make UTF-8 the default coding system: @@ -313,7 +313,7 @@ users).") ;; collect; staving off the collector while the user is working. (setq gcmh-idle-delay 5 gcmh-high-cons-threshold (* 16 1024 1024) ; 16mb - gcmh-verbose doom-debug-mode) + gcmh-verbose doom-debug-p) ;; HACK `tty-run-terminal-initialization' is *tremendously* slow for some ;; reason. Disabling it completely could have many side-effects, so we @@ -534,6 +534,7 @@ to least)." (add-hook-trigger! 'doom-first-buffer-hook 'after-find-file 'doom-switch-buffer-hook)) (add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h) (add-hook 'window-setup-hook #'doom-display-benchmark-h 'append) + (if doom-debug-p (doom-debug-mode +1)) ;; Load core/core-*.el, the user's private init.el and their config.el (doom-initialize-modules force-p)) diff --git a/core/test/test-core.el b/core/test/test-core.el index 8a0844cd5..09d5b3fcc 100644 --- a/core/test/test-core.el +++ b/core/test/test-core.el @@ -2,9 +2,9 @@ ;;; core/test/test-core.el (describe "core" - :var (doom-interactive-mode) + :var (doom-interactive-p) (before-each - (setq doom-interactive-mode nil)) + (setq doom-interactive-p nil)) (describe "initialization" (describe "doom-initialize" @@ -33,7 +33,7 @@ (expect 'doom-initialize-packages :to-have-been-called)) (it "doesn't initialize packages if core autoload file was loaded" - (let ((doom-interactive-mode t)) + (let ((doom-interactive-p t)) (spy-on 'doom-load-autoloads-file :and-return-value t) (doom-initialize nil 'noerror) (expect 'doom-load-autoloads-file :to-have-been-called-with doom-package-autoload-file) diff --git a/modules/editor/evil/init.el b/modules/editor/evil/init.el index 3c629003b..ce58fe724 100644 --- a/modules/editor/evil/init.el +++ b/modules/editor/evil/init.el @@ -19,7 +19,7 @@ ;; disable modules, and to reduce the effort required to maintain our copy of ;; `evil-collection-list' (now I can just copy it from time to time). -(when (and doom-interactive-mode +(when (and doom-interactive-p (not doom-reloading-p) (featurep! +everywhere)) diff --git a/modules/editor/snippets/config.el b/modules/editor/snippets/config.el index b888cfb13..f594245c0 100644 --- a/modules/editor/snippets/config.el +++ b/modules/editor/snippets/config.el @@ -38,7 +38,7 @@ ;; Reduce verbosity. 3 is too chatty about initializing yasnippet. 2 is just ;; right (only shows errors). - (setq yas-verbosity (if doom-debug-mode 3 0)) + (setq yas-verbosity (if doom-debug-p 3 0)) ;; default snippets library, if available (add-to-list 'load-path +snippets-dir) diff --git a/modules/tools/lookup/config.el b/modules/tools/lookup/config.el index 22f944972..a2d7e8b6a 100644 --- a/modules/tools/lookup/config.el +++ b/modules/tools/lookup/config.el @@ -181,7 +181,7 @@ Dictionary.app behind the scenes to get definitions.") :init (add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend-fn) :config - (setq dash-docs-enable-debugging doom-debug-mode + (setq dash-docs-enable-debugging doom-debug-p dash-docs-docsets-path (concat doom-etc-dir "docsets/") dash-docs-min-length 2 dash-docs-browser-func #'eww) diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index 9e9025dee..0664dcab3 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -65,7 +65,7 @@ (setq-hook! 'pdf-view-mode-hook evil-normal-state-cursor (list nil)) ;; Install epdfinfo binary if needed, blocking until it is finished - (when doom-interactive-mode + (when doom-interactive-p (require 'pdf-tools) (unless (file-executable-p pdf-info-epdfinfo-program) (let ((wconf (current-window-configuration)))