refactor: remove unused core variables

doom-debug-p and doom-interactive-p have always been intentionally
redundant, because changing the variables they replaced had other
side-effects, which made writing tests for them difficult. Since our
new (yet unpublished) tests lean heavily toward integration testing more
than unit testing, this becomes an implementation detail.

And doom-init-p's only use was refactor out at some point in the past,
so it's no longer used.

Also done to reduce Doom's footprint, in general.
This commit is contained in:
Henrik Lissner 2022-06-24 21:15:31 +02:00
parent 74cc541597
commit 14b2395424
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
22 changed files with 55 additions and 76 deletions

View file

@ -230,7 +230,7 @@ SEE ALSO:
(dolist (file loads)
(load (doom-path (cdr file))
(not (equal (car file) "--strict-load"))
(not doom-debug-p) t))
(not init-file-debug) t))
(dolist (form evals)
(eval (read (cdr form)) t)))

View file

@ -8,7 +8,6 @@
'(async-debug
debug-on-error
(debugger . doom-debugger)
doom-debug-p
(doom-print-level . debug)
garbage-collection-messages
gcmh-verbose
@ -33,7 +32,7 @@ symbol and CDR is the value to set it to when `doom-debug-mode' is activated.")
;;;###autoload
(define-minor-mode doom-debug-mode
"Toggle `debug-on-error' and `doom-debug-p' for verbose logging."
"Toggle `debug-on-error' and `init-file-debug' for verbose logging."
:init-value nil
:global t
(let ((enabled doom-debug-mode))
@ -246,7 +245,7 @@ ready to be pasted in a bug report on github."
. ,(mapcar
#'symbol-name
(delq
nil (list (cond ((not doom-interactive-p) 'batch)
nil (list (cond (noninteractive 'batch)
((display-graphic-p) 'gui)
('tty))
(if (daemonp) 'daemon)

View file

@ -110,13 +110,12 @@ Any of these classes can be called like functions from within `format!' and
(defvar doom-print-indent-increment 2
"Steps in which to increment `doom-print-indent' for consecutive levels.")
(defvar doom-print-backend
(if doom-interactive-p 'text-properties 'ansi)
(defvar doom-print-backend (if noninteractive 'ansi 'text-properties)
"Whether to print colors/styles with ANSI codes or with text properties.
Accepts `ansi' and `text-properties'. `nil' means don't render styles at all.")
(defvar doom-print-level (if doom-debug-p 'debug 'info)
(defvar doom-print-level (if init-file-debug 'debug 'info)
"The default level of messages to print.")
(defvar doom-print-logging-level 'debug
@ -178,7 +177,7 @@ Returns OUTPUT."
Does not emit the message in the echo area. This is a macro instead of a
function to prevent the potentially expensive execution of its arguments when
debug mode is off."
`(when (or doom-debug-p (not doom-interactive-p))
`(when (or init-file-debug noninteractive)
(let ((inhibit-message t))
(message
"%s" (propertize

View file

@ -6,7 +6,7 @@
;; while it is lexically bound, you get "Defining as dynamic an already
;; lexical var" errors in Emacs 28+).
;;;###autoload (defvar projectile-project-root nil)
;;;###autoload (defvar projectile-enable-caching doom-interactive-p)
;;;###autoload (defvar projectile-enable-caching (not noninteractive))
;;;###autoload (defvar projectile-require-project-root 'prompt)
;;;###autodef

View file

@ -60,7 +60,7 @@
forms
`(progn
;; doom variables
(setq doom-debug-p t
(setq init-file-debug t
doom-emacs-dir ,doom-emacs-dir
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
doom-etc-dir ,(expand-file-name "etc/" doom-sandbox-dir))
@ -71,7 +71,7 @@
;; emacs essential variables
(setq before-init-time (current-time)
after-init-time nil
init-file-debug doom-debug-p
init-file-debug init-file-debug
noninteractive nil
process-environment (get 'process-environment 'initial-value)
exec-path (get 'exec-path 'initial-value)

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
(when doom-interactive-p
(unless noninteractive
(add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h))

View file

@ -64,7 +64,7 @@ one wants that.")
doom-autoloads-excluded-files
'literal)
;; TODO Uncomment when profile system is implemented
;; `((if doom-interactive-p (require 'core-start)))
;; `((unless noninteractive (require 'core-start)))
)
(print! (start "Byte-compiling autoloads file..."))
(doom-autoloads--compile-file file)
@ -91,7 +91,7 @@ one wants that.")
(defun doom-autoloads--compile-file (file)
(condition-case-unless-debug e
(let ((byte-compile-warnings (if doom-debug-p byte-compile-warnings)))
(let ((byte-compile-warnings (if init-file-debug byte-compile-warnings)))
(and (byte-compile-file file)
(load (byte-compile-dest-file file) nil t)))
(error

View file

@ -95,8 +95,7 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
;; But first we must be sure that Doom and your private config have been
;; fully loaded. Which usually aren't so in an noninteractive session.
(let ((load-prefer-newer t)
(noninteractive t)
doom-interactive-p)
(noninteractive t))
(require 'core-start)
(quiet! (doom-initialize-packages))
(quiet! (doom-initialize-modules))))
@ -198,7 +197,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-p "" "\033[1A")
with esc = (if init-file-debug "" "\033[1A")
for path
in (append (doom-glob doom-emacs-dir "*.elc")
(doom-files-in doom-private-dir :match "\\.elc$" :depth 1)

View file

@ -158,8 +158,7 @@ in."
(print! (start "Checking Doom Emacs..."))
(condition-case-unless-debug ex
(print-group!
(let ((doom-interactive-p 'doctor)
(noninteractive nil)
(let ((noninteractive nil)
kill-emacs-query-functions
kill-emacs-hook)
(defvar doom-reloading-p nil)

View file

@ -86,8 +86,6 @@ Why this over exec-path-from-shell?
"Regenerating"
"Generating"))
(print-group!
(when doom-interactive-p
(user-error "doom env: must be run on the command line, not an interactive session"))
(goto-char (point-min))
(insert
";; -*- mode: lisp-interaction; coding: utf-8-unix; -*-\n"

View file

@ -133,7 +133,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-p "\033[1A"))
(let ((esc (unless init-file-debug "\033[1A"))
(ref (straight-vc-get-commit type local-repo))
newref output)
(print! (start "\033[KUpdating recipes for %s...%s") package esc)
@ -401,7 +401,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-p "\033[1A"))
(esc (unless init-file-debug "\033[1A"))
(i 0)
errors)
(print! (start "Updating packages (this may take a while)..."))
@ -723,9 +723,9 @@ it doesn't make sense to slack."
(defadvice! doom-cli--straight-fallback-to-y-or-n-prompt-a (fn &optional prompt noprompt?)
:around #'straight-are-you-sure
(or noprompt?
(if doom-interactive-p
(funcall fn prompt)
(y-or-n-p (format! "%s" (or prompt ""))))))
(if noninteractive
(y-or-n-p (format! "%s" (or prompt "")))
(funcall fn prompt))))
(defun doom-cli--straight-recommended-option-p (prompt option)
(cl-loop for (prompt-re . opt-re) in doom-cli--straight-auto-options

View file

@ -1009,7 +1009,7 @@ shown."
(seconds (- duration (* hours 60 60) (* minutes 60)))
(standard-output
(if (and (/= doom-cli--exit-code 0)
(or doom-debug-p
(or init-file-debug
(eq (doom-cli-prop cli :benchmark) t)
(and (eq (doom-cli-prop cli :benchmark :null) :null)
(not (doom-cli-context-pipe-p context 'out t))
@ -1100,7 +1100,7 @@ Emacs' batch library lacks an implementation of the exec system call."
(insert "#!/usr/bin/env sh\n"
"trap _doomcleanup EXIT\n"
"_doomcleanup() {\n"
" rm -" (if doom-debug-p "v" "") "f "
" rm -" (if init-file-debug "v" "") "f "
(combine-and-quote-strings (delq nil (list script-file context-file)))
"\n}\n"
"_doomrun() {\n " command "\n}\n"
@ -1195,7 +1195,7 @@ ARGS are options passed to less. If DOOMPAGER is set, ARGS are ignored."
(append (if doom-print-backend '("-r")) ; process ANSI codes
(or (delq nil args) '("+g"))))
(shell-quote-argument tmpfile)
(if doom-debug-p "v" "")
(if init-file-debug "v" "")
(shell-quote-argument tmpfile))
context)))))

View file

@ -484,7 +484,7 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(use-package! dtrt-indent
;; Automatic detection of indent settings
:when doom-interactive-p
:unless noninteractive
;; I'm not using `global-dtrt-indent-mode' because it has hard-coded and rigid
;; major mode checks, so I implement it in `doom-detect-indentation-h'.
:hook ((change-major-mode-after-body read-only-mode) . doom-detect-indentation-h)
@ -496,7 +496,7 @@ files, so this 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-p)))
(let ((inhibit-message (not init-file-debug)))
(dtrt-indent-mode +1))))
;; Enable dtrt-indent even in smie modes so that it can update `tab-width',

View file

@ -264,12 +264,9 @@ NAME, ARGLIST, and BODY are the same as `defun', `defun*', `defmacro', and
This silences calls to `message', `load', `write-region' and anything that
writes to `standard-output'. In interactive sessions this inhibits output to the
echo-area, but not to *Messages*."
`(if doom-debug-p
`(if init-file-debug
(progn ,@forms)
,(if doom-interactive-p
`(let ((inhibit-message t)
(save-silently t))
(prog1 ,@forms (message "")))
,(if noninteractive
`(letf! ((standard-output (lambda (&rest _)))
(defun message (&rest _))
(defun load (file &optional noerror nomessage nosuffix must-suffix)
@ -277,7 +274,10 @@ echo-area, but not to *Messages*."
(defun write-region (start end filename &optional append visit lockname mustbenew)
(unless visit (setq visit 'no-message))
(funcall write-region start end filename append visit lockname mustbenew)))
,@forms))))
,@forms)
`(let ((inhibit-message t)
(save-silently t))
(prog1 ,@forms (message ""))))))
(defmacro eval-if! (cond then &rest body)
"Expands to THEN if COND is non-nil, to BODY otherwise.

View file

@ -66,7 +66,7 @@ syntax-checker modules obsolete. e.g. If :feature version-control is found in
your `doom!' block, a warning is emitted before replacing it with :emacs vc and
:ui vc-gutter.")
(defvar doom-inhibit-module-warnings doom-interactive-p
(defvar doom-inhibit-module-warnings (not noninteractive)
"If non-nil, don't emit deprecated or missing module warnings at startup.")
;;; Custom hooks
@ -309,7 +309,7 @@ those directories. The first returned path is always `doom-private-dir'."
:flags (if (listp m) (cdr m))
:path (if (stringp path) (file-truename path)))
results)))))))
(unless doom-interactive-p
(when noninteractive
(setq doom-inhibit-module-warnings t))
(nreverse results)))
@ -328,10 +328,10 @@ This value is cached. If REFRESH-P, then don't use the cached value."
(autoload 'use-package "use-package-core" nil nil t)
(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)
(setq use-package-compute-statistics init-file-debug
use-package-verbose init-file-debug
use-package-minimum-reported-time (if init-file-debug 0 0.1)
use-package-expand-minimally (not noninteractive))
;; A common mistake for new users is that they inadvertently install their
;; packages with package.el, by copying over old `use-package' declarations with
@ -474,7 +474,7 @@ The overall load order of Doom is as follows:
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
for a list of all recognized module trees. Order defines precedence (from most
to least)."
`(unless doom-interactive-p
`(when noninteractive
(doom-module-mplist-map
(lambda (category module &rest plist)
(if (plist-member plist :path)

View file

@ -120,7 +120,7 @@ uses a straight or package.el command directly).")
"://github.com/"
(or (plist-get recipe :repo) "radian-software/straight.el")))
(branch (or (plist-get recipe :branch) straight-repository-branch))
(call (if doom-debug-p
(call (if init-file-debug
(lambda (&rest args)
(print! "%s" (cdr (apply #'doom-call-process args))))
(lambda (&rest args)

View file

@ -30,7 +30,7 @@ debian, and derivatives). On most it's 'fd'.")
;; Auto-discovery is slow to do by default. Better to update the list
;; when you need to (`projectile-discover-projects-in-search-path').
projectile-auto-discover nil
projectile-enable-caching doom-interactive-p
projectile-enable-caching (not noninteractive)
projectile-globally-ignored-files '(".DS_Store" "TAGS")
projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o")
projectile-kill-buffers-filter 'kill-only-files
@ -115,8 +115,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)
projectile-enable-caching
doom-interactive-p)
projectile-enable-caching)
(setq projectile-known-projects
(cl-remove-if #'projectile-ignored-project-p
projectile-known-projects))

View file

@ -115,18 +115,6 @@
(defconst doom-modules-version "22.06.0-dev"
"Current version of Doom Emacs.")
(defvar doom-debug-p (or (getenv-internal "DEBUG") init-file-debug)
"If non-nil, Doom will log more.
Use `doom-debug-mode' to toggle it. The --debug-init flag and setting the DEBUG
envvar will enable this at startup.")
(defvar doom-init-p nil
"Non-nil if Doom has been initialized.")
(defconst doom-interactive-p (not noninteractive)
"If non-nil, Emacs is in interactive mode.")
;;
;;; Directory variables

View file

@ -69,8 +69,6 @@
"--eval"
(prin1-to-string
`(progn
(defvar doom-interactive-p nil)
(defvar doom-debug-p ,doom-debug-p)
(require 'cl-lib)
(require 'subr-x)
(load ,(doom-path doom-core-dir "autoload/print"))
@ -111,10 +109,10 @@
(defun +literate-tangle-h ()
"Tangles `+literate-config-file' if it has changed.
This is performed with an asyncronous Emacs process, except when
`doom-interactive-p' is non-nil."
(if doom-interactive-p
(+literate-tangle--async)
(+literate-tangle--sync)))
`noninteractive' is nil."
(if noninteractive
(+literate-tangle--sync)
(+literate-tangle--async)))
;;;###autoload
(defun +literate-tangle-check-finished-h ()

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-p
(when (and (not noninteractive)
(not doom-reloading-p)
(featurep! +everywhere))

View file

@ -34,7 +34,7 @@
;; Reduce verbosity. 3 is too chatty about initializing yasnippet. 2 is just
;; right (only shows errors).
(setq yas-verbosity (if doom-debug-p 3 0))
(setq yas-verbosity (if init-file-debug 3 0))
;; default snippets library, if available
(add-to-list 'load-path +snippets-dir)

View file

@ -197,7 +197,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-p
(setq dash-docs-enable-debugging init-file-debug
dash-docs-docsets-path (concat doom-etc-dir "docsets/")
dash-docs-min-length 2
dash-docs-browser-func #'eww)