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
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
20 changed files with 50 additions and 48 deletions

View file

@ -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")

View file

@ -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</details>"))
(if noninteractive
(if (not doom-interactive-p)
(print! (buffer-string))
(switch-to-buffer buffer)
(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)))
;;;###autoload
(unless noninteractive
(when doom-interactive-p
(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)
(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

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.
(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)

View file

@ -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))

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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',

View file

@ -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 "")))

View file

@ -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))

View file

@ -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

View file

@ -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))

View file

@ -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))

View file

@ -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)

View file

@ -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))

View file

@ -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)

View file

@ -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)

View file

@ -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)))