Change doom-{interactive,debug}-mode suffix to -p

Because these are not really modes.

Also makes `doom-debug-mode` an actual (global) minor mode.
This commit is contained in:
Henrik Lissner
2020-05-25 02:58:07 -04:00
parent 4f46140226
commit 3a38fc633c
20 changed files with 50 additions and 48 deletions

View File

@ -31,7 +31,7 @@
(defcli! :main (defcli! :main
((help-p ["-h" "--help"] "Same as help command") ((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") (yes-p ["-y" "--yes"] "Auto-accept all confirmation prompts")
(emacsdir ["--emacsdir" dir] "Use the emacs config at DIR (e.g. ~/.emacs.d)") (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)") (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)) (print! (info "DOOMLOCALDIR=%s") localdir))
(when debug-p (when debug-p
(setenv "DEBUG" "1") (setenv "DEBUG" "1")
(setq doom-debug-mode t) (setq doom-debug-p t)
(print! (info "Debug mode on"))) (print! (info "Debug mode on")))
(when yes-p (when yes-p
(setenv "YES" "1") (setenv "YES" "1")

View File

@ -5,7 +5,7 @@
;;;###autoload ;;;###autoload
(defvar doom-debug-variables (defvar doom-debug-variables
'(doom-debug-mode '(doom-debug-p
init-file-debug init-file-debug
debug-on-error debug-on-error
garbage-collection-messages garbage-collection-messages
@ -18,9 +18,10 @@
"A list of variable to toggle on `doom/toggle-debug-mode'.") "A list of variable to toggle on `doom/toggle-debug-mode'.")
;;;###autoload ;;;###autoload
(defun doom/toggle-debug-mode (&optional arg) (define-minor-mode doom-debug-mode
"Toggle `debug-on-error' and `doom-debug-mode' for verbose logging." "Toggle `debug-on-error' and `doom-debug-p' for verbose logging."
(interactive (list (or current-prefix-arg 'toggle))) :init-value doom-debug-p
:global t
(let ((value (let ((value
(cond ((eq arg 'toggle) (not doom-debug-mode)) (cond ((eq arg 'toggle) (not doom-debug-mode))
((> (prefix-numeric-value arg) 0))))) ((> (prefix-numeric-value arg) 0)))))
@ -77,7 +78,7 @@ ready to be pasted in a bug report on github."
(features ,@system-configuration-features) (features ,@system-configuration-features)
(build . ,(format-time-string "%b %d, %Y" emacs-build-time)) (build . ,(format-time-string "%b %d, %Y" emacs-build-time))
(buildopts ,system-configuration-options) (buildopts ,system-configuration-options)
(windowsys . ,(if noninteractive 'batch window-system)) (windowsys . ,(if doom-interactive-p window-system 'batch))
(daemonp . ,(cond ((daemonp) 'daemon) (daemonp . ,(cond ((daemonp) 'daemon)
((and (require 'server) ((and (require 'server)
(server-running-p)) (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*")) (let ((buffer (get-buffer-create "*doom-info*"))
(info (doom-info))) (info (doom-info)))
(with-current-buffer buffer (with-current-buffer buffer
(unless (or noninteractive (or (not doom-interactive-p)
(eq major-mode 'markdown-mode) (eq major-mode 'markdown-mode)
(not (fboundp 'markdown-mode))) (not (fboundp 'markdown-mode))
(markdown-mode)) (markdown-mode))
(erase-buffer) (erase-buffer)
(if raw (if raw
(progn (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") (insert! (indent 8 "%-10s %s\n")
((car spec) (cdr spec))))) ((car spec) (cdr spec)))))
(insert "```\n</details>")) (insert "```\n</details>"))
(if noninteractive (if (not doom-interactive-p)
(print! (buffer-string)) (print! (buffer-string))
(switch-to-buffer buffer) (switch-to-buffer buffer)
(kill-new (buffer-string)) (kill-new (buffer-string))

View File

@ -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))) (remove-hook 'doom-switch-buffer-hook #'doom-persist-scratch-buffers-after-switch-h)))
;;;###autoload ;;;###autoload
(unless noninteractive (when doom-interactive-p
(add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h)) (add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h))

View File

@ -91,10 +91,10 @@ one wants that.")
(defun doom-cli--byte-compile-file (file) (defun doom-cli--byte-compile-file (file)
(condition-case-unless-debug e (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)) (byte-compile-dynamic-docstrings t))
(when (byte-compile-file file) (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)) (add-hook 'doom-cli-post-success-execute-hook #'doom-cli--warn-refresh-session-h))
(load (byte-compile-dest-file file) nil t))) (load (byte-compile-dest-file file) nil t)))
(error (error

View File

@ -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. ;; fully loaded. Which usually aren't so in an noninteractive session.
(let ((load-prefer-newer t) (let ((load-prefer-newer t)
(noninteractive t) (noninteractive t)
doom-interactive-mode) doom-interactive-p)
(doom-initialize 'force) (doom-initialize 'force)
(quiet! (doom-initialize-packages)))) (quiet! (doom-initialize-packages))))
@ -180,7 +180,7 @@ module. This does not include your byte-compiled, third party packages.'"
(print-group! (print-group!
(cl-loop with default-directory = doom-emacs-dir (cl-loop with default-directory = doom-emacs-dir
with success = 0 with success = 0
with esc = (if doom-debug-mode "" "\033[1A") with esc = (if doom-debug-p "" "\033[1A")
for path for path
in (append (doom-glob doom-emacs-dir "*.elc") in (append (doom-glob doom-emacs-dir "*.elc")
(doom-files-in doom-private-dir :match "\\.elc$" :depth 1) (doom-files-in doom-private-dir :match "\\.elc$" :depth 1)

View File

@ -79,7 +79,7 @@ in."
(print! (start "Checking Doom Emacs...")) (print! (start "Checking Doom Emacs..."))
(condition-case-unless-debug ex (condition-case-unless-debug ex
(print-group! (print-group!
(let ((doom-interactive-mode 'doctor)) (let ((doom-interactive-p 'doctor))
(doom-initialize 'force) (doom-initialize 'force)
(doom-initialize-modules)) (doom-initialize-modules))

View File

@ -95,7 +95,7 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
"Generating") "Generating")
(path env-file)) (path env-file))
(print-group! (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")) (user-error "'doom env' must be run on the command line, not an interactive session"))
(goto-char (point-min)) (goto-char (point-min))
(insert (insert

View File

@ -106,7 +106,7 @@ list remains lean."
nil (mapcar (doom-rpartial #'gethash straight--repo-cache) nil (mapcar (doom-rpartial #'gethash straight--repo-cache)
(mapcar #'symbol-name straight-recipe-repositories))) (mapcar #'symbol-name straight-recipe-repositories)))
(recipe package type local-repo) (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)) (ref (straight-vc-get-commit type local-repo))
newref output) newref output)
(print! (start "\033[KUpdating recipes for %s...%s") package esc) (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)) (packages-to-rebuild (make-hash-table :test 'equal))
(repos-to-rebuild (make-hash-table :test 'equal)) (repos-to-rebuild (make-hash-table :test 'equal))
(total (length recipes)) (total (length recipes))
(esc (unless doom-debug-mode "\033[1A")) (esc (unless doom-debug-p "\033[1A"))
(i 0) (i 0)
errors) errors)
(when recipes (when recipes

View File

@ -257,7 +257,7 @@ original state.")
(defadvice! doom--straight-fallback-to-y-or-n-prompt-a (orig-fn &optional prompt) (defadvice! doom--straight-fallback-to-y-or-n-prompt-a (orig-fn &optional prompt)
:around #'straight-are-you-sure :around #'straight-are-you-sure
(or doom-auto-accept (or doom-auto-accept
(if doom-interactive-mode (if doom-interactive-p
(funcall orig-fn prompt) (funcall orig-fn prompt)
(y-or-n-p (format! "%s" (or 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) (defadvice! doom--straight-fallback-to-tty-prompt-a (orig-fn prompt actions)
"Modifies straight to prompt on the terminal when in noninteractive sessions." "Modifies straight to prompt on the terminal when in noninteractive sessions."
:around #'straight--popup-raw :around #'straight--popup-raw
(if doom-interactive-mode (if doom-interactive-p
(funcall orig-fn prompt actions) (funcall orig-fn prompt actions)
(let ((doom--straight-discard-options doom--straight-discard-options)) (let ((doom--straight-discard-options doom--straight-discard-options))
;; We can't intercept C-g, so no point displaying any options for this key ;; We can't intercept C-g, so no point displaying any options for this key

View File

@ -359,7 +359,7 @@ files, so we replace calls to `pp' with the much faster `prin1'."
(use-package! dtrt-indent (use-package! dtrt-indent
;; Automatic detection of indent settings ;; 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) :hook ((change-major-mode-after-body read-only-mode) . doom-detect-indentation-h)
:config :config
(defun doom-detect-indentation-h () (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) (memq major-mode doom-detect-indentation-excluded-modes)
(member (substring (buffer-name) 0 1) '(" " "*"))) (member (substring (buffer-name) 0 1) '(" " "*")))
;; Don't display messages in the echo area, but still log them ;; 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)))) (dtrt-indent-mode +1))))
;; Enable dtrt-indent even in smie modes so that it can update `tab-width', ;; Enable dtrt-indent even in smie modes so that it can update `tab-width',

View File

@ -66,10 +66,10 @@ list is returned as-is."
(substring (symbol-name keyword) 1)) (substring (symbol-name keyword) 1))
(defmacro doom-log (format-string &rest args) (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*. Does not interrupt the minibuffer if it is in use, but still logs to *Messages*.
Accepts the same arguments as `message'." Accepts the same arguments as `message'."
`(when doom-debug-mode `(when doom-debug-p
(let ((inhibit-message (active-minibuffer-window))) (let ((inhibit-message (active-minibuffer-window)))
(message (message
,(concat (propertize "DOOM " 'face 'font-lock-comment-face) ,(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 This silences calls to `message', `load', `write-region' and anything that
writes to `standard-output'." writes to `standard-output'."
`(if doom-debug-mode `(if doom-debug-p
(progn ,@forms) (progn ,@forms)
,(if doom-interactive-mode ,(if doom-interactive-p
`(let ((inhibit-message t) `(let ((inhibit-message t)
(save-silently t)) (save-silently t))
(prog1 ,@forms (message ""))) (prog1 ,@forms (message "")))

View File

@ -258,10 +258,10 @@ This value is cached. If REFRESH-P, then don't use the cached value."
(eval-and-compile (eval-and-compile
(autoload 'use-package "use-package-core" nil nil t) (autoload 'use-package "use-package-core" nil nil t)
(setq use-package-compute-statistics doom-debug-mode (setq use-package-compute-statistics doom-debug-p
use-package-verbose doom-debug-mode use-package-verbose doom-debug-p
use-package-minimum-reported-time (if doom-debug-mode 0 0.1) use-package-minimum-reported-time (if doom-debug-p 0 0.1)
use-package-expand-minimally doom-interactive-mode)) use-package-expand-minimally doom-interactive-p))
(defvar doom--deferred-packages-alist '(t)) (defvar doom--deferred-packages-alist '(t))

View File

@ -110,7 +110,7 @@ package's name as a symbol, and whose CDR is the plist supplied to its
"://github.com/" "://github.com/"
(or (plist-get recipe :repo) "raxod502/straight.el"))) (or (plist-get recipe :repo) "raxod502/straight.el")))
(branch (or (plist-get recipe :branch) straight-repository-branch)) (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)) (if (not (file-directory-p repo-dir))
(message "Installing straight...") (message "Installing straight...")
;; TODO Rethink this clumsy workaround ;; TODO Rethink this clumsy workaround

View File

@ -26,7 +26,7 @@ Emacs.")
projectile-locate-dominating-file) projectile-locate-dominating-file)
:init :init
(setq projectile-cache-file (concat doom-cache-dir "projectile.cache") (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 projectile-globally-ignored-files '(".DS_Store" "Icon
" "TAGS") " "TAGS")
projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o") projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o")
@ -112,7 +112,7 @@ b) represent blacklisted directories that are too big, change too often or are
b) represent blacklisted directories that are too big, change too often or are b) represent blacklisted directories that are too big, change too often or are
private. (see `doom-projectile-cache-blacklist'), private. (see `doom-projectile-cache-blacklist'),
c) are not valid projectile projects." c) are not valid projectile projects."
(when (and (bound-and-true-p projectile-projects-cache) (when (and (bound-and-true-p projectile-projects-cache)
doom-interactive-p) doom-interactive-p)
(cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist) (cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist)
for proot in (hash-table-keys projectile-projects-cache) for proot in (hash-table-keys projectile-projects-cache)

View File

@ -63,13 +63,13 @@
(defvar doom-init-time nil (defvar doom-init-time nil
"The time it took, in seconds, for Doom Emacs to initialize.") "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. "If non-nil, Doom will log more.
Use `doom/toggle-debug-mode' to toggle it. The --debug-init flag and setting the Use `doom/toggle-debug-mode' to toggle it. The --debug-init flag and setting the
DEBUG envvar will enable this at startup.") 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.") "If non-nil, Emacs is in interactive mode.")
;;; Directories/files ;;; Directories/files
@ -157,8 +157,8 @@ users).")
(setq message-log-max 8192) (setq message-log-max 8192)
;; Reduce debug output, well, unless we've asked for it. ;; Reduce debug output, well, unless we've asked for it.
(setq debug-on-error doom-debug-mode (setq debug-on-error doom-debug-p
jka-compr-verbose doom-debug-mode) jka-compr-verbose doom-debug-p)
;; Contrary to what many Emacs users have in their configs, you really don't ;; 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: ;; 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. ;; collect; staving off the collector while the user is working.
(setq gcmh-idle-delay 5 (setq gcmh-idle-delay 5
gcmh-high-cons-threshold (* 16 1024 1024) ; 16mb 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 ;; HACK `tty-run-terminal-initialization' is *tremendously* slow for some
;; reason. Disabling it completely could have many side-effects, so we ;; 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-trigger! 'doom-first-buffer-hook 'after-find-file 'doom-switch-buffer-hook))
(add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h) (add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h)
(add-hook 'window-setup-hook #'doom-display-benchmark-h 'append) (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 ;; Load core/core-*.el, the user's private init.el and their config.el
(doom-initialize-modules force-p)) (doom-initialize-modules force-p))

View File

@ -2,9 +2,9 @@
;;; core/test/test-core.el ;;; core/test/test-core.el
(describe "core" (describe "core"
:var (doom-interactive-mode) :var (doom-interactive-p)
(before-each (before-each
(setq doom-interactive-mode nil)) (setq doom-interactive-p nil))
(describe "initialization" (describe "initialization"
(describe "doom-initialize" (describe "doom-initialize"
@ -33,7 +33,7 @@
(expect 'doom-initialize-packages :to-have-been-called)) (expect 'doom-initialize-packages :to-have-been-called))
(it "doesn't initialize packages if core autoload file was loaded" (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) (spy-on 'doom-load-autoloads-file :and-return-value t)
(doom-initialize nil 'noerror) (doom-initialize nil 'noerror)
(expect 'doom-load-autoloads-file :to-have-been-called-with doom-package-autoload-file) (expect 'doom-load-autoloads-file :to-have-been-called-with doom-package-autoload-file)

View File

@ -19,7 +19,7 @@
;; disable modules, and to reduce the effort required to maintain our copy of ;; 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). ;; `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) (not doom-reloading-p)
(featurep! +everywhere)) (featurep! +everywhere))

View File

@ -38,7 +38,7 @@
;; Reduce verbosity. 3 is too chatty about initializing yasnippet. 2 is just ;; Reduce verbosity. 3 is too chatty about initializing yasnippet. 2 is just
;; right (only shows errors). ;; 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 ;; default snippets library, if available
(add-to-list 'load-path +snippets-dir) (add-to-list 'load-path +snippets-dir)

View File

@ -181,7 +181,7 @@ Dictionary.app behind the scenes to get definitions.")
:init :init
(add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend-fn) (add-hook '+lookup-documentation-functions #'+lookup-dash-docsets-backend-fn)
:config :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-docsets-path (concat doom-etc-dir "docsets/")
dash-docs-min-length 2 dash-docs-min-length 2
dash-docs-browser-func #'eww) dash-docs-browser-func #'eww)

View File

@ -65,7 +65,7 @@
(setq-hook! 'pdf-view-mode-hook evil-normal-state-cursor (list nil)) (setq-hook! 'pdf-view-mode-hook evil-normal-state-cursor (list nil))
;; Install epdfinfo binary if needed, blocking until it is finished ;; Install epdfinfo binary if needed, blocking until it is finished
(when doom-interactive-mode (when doom-interactive-p
(require 'pdf-tools) (require 'pdf-tools)
(unless (file-executable-p pdf-info-epdfinfo-program) (unless (file-executable-p pdf-info-epdfinfo-program)
(let ((wconf (current-window-configuration))) (let ((wconf (current-window-configuration)))