refactor(lib): s/doom--debug-/doom-debug-/

To uphold conventions introduced in 6c0b7e1.

Ref: 6c0b7e1530
This commit is contained in:
Henrik Lissner 2022-07-30 21:20:56 +02:00
parent 964b7dcbee
commit 510032bcb0
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -21,10 +21,10 @@
Each entry can be a variable symbol or a cons cell whose CAR is the variable Each entry can be a variable symbol or a cons cell whose CAR is the variable
symbol and CDR is the value to set it to when `doom-debug-mode' is activated.") symbol and CDR is the value to set it to when `doom-debug-mode' is activated.")
(defvar doom--debug-vars-undefined nil) (defvar doom-debug--undefined-vars nil)
(defun doom--watch-debug-vars-h (&rest _) (defun doom-debug--watch-vars-h (&rest _)
(when-let (bound-vars (cl-remove-if-not #'boundp doom--debug-vars-undefined)) (when-let (bound-vars (cl-delete-if-not #'boundp doom-debug--undefined-vars))
(doom-log "New variables available: %s" bound-vars) (doom-log "New variables available: %s" bound-vars)
(let ((message-log-max nil)) (let ((message-log-max nil))
(doom-debug-mode -1) (doom-debug-mode -1)
@ -33,13 +33,13 @@ symbol and CDR is the value to set it to when `doom-debug-mode' is activated.")
;;;###autoload ;;;###autoload
(define-minor-mode doom-debug-mode (define-minor-mode doom-debug-mode
"Toggle `debug-on-error' and `init-file-debug' for verbose logging." "Toggle `debug-on-error' and `init-file-debug' for verbose logging."
:init-value nil :init-value init-file-debug
:global t :global t
(let ((enabled doom-debug-mode)) (let ((enabled doom-debug-mode))
(setq doom--debug-vars-undefined nil) (setq doom-debug--undefined-vars nil)
(dolist (var doom-debug-variables) (dolist (var doom-debug-variables)
(cond ((listp var) (cond ((listp var)
(cl-destructuring-bind (var . val) var (pcase-let ((`(,var . ,val) var))
(if (boundp var) (if (boundp var)
(set-default (set-default
var (if (not enabled) var (if (not enabled)
@ -47,10 +47,10 @@ symbol and CDR is the value to set it to when `doom-debug-mode' is activated.")
(put 'x 'initial-value nil)) (put 'x 'initial-value nil))
(put var 'initial-value (symbol-value var)) (put var 'initial-value (symbol-value var))
val)) val))
(add-to-list 'doom--debug-vars-undefined var)))) (add-to-list 'doom-debug--undefined-vars var))))
((if (boundp var) ((if (boundp var)
(set-default var enabled) (set-default var enabled)
(add-to-list 'doom--debug-vars-undefined var))))) (add-to-list 'doom-debug--undefined-vars var)))))
(when (called-interactively-p 'any) (when (called-interactively-p 'any)
(when (fboundp 'explain-pause-mode) (when (fboundp 'explain-pause-mode)
(explain-pause-mode (if enabled +1 -1)))) (explain-pause-mode (if enabled +1 -1))))
@ -65,13 +65,13 @@ symbol and CDR is the value to set it to when `doom-debug-mode' is activated.")
(advice-add #'run-hooks :override #'doom-run-hooks) (advice-add #'run-hooks :override #'doom-run-hooks)
;; Add time stamps to lines in *Messages* ;; Add time stamps to lines in *Messages*
(advice-add #'message :before #'doom--timestamped-message-a) (advice-add #'message :before #'doom--timestamped-message-a)
(add-variable-watcher 'doom-debug-variables #'doom--watch-debug-vars-h) (add-variable-watcher 'doom-debug-variables #'doom-debug--watch-vars-h)
(add-hook 'after-load-functions #'doom--watch-debug-vars-h)) (add-hook 'after-load-functions #'doom-debug--watch-vars-h))
(t (t
(advice-remove #'run-hooks #'doom-run-hooks) (advice-remove #'run-hooks #'doom-run-hooks)
(advice-remove #'message #'doom--timestamped-message-a) (advice-remove #'message #'doom--timestamped-message-a)
(remove-variable-watcher 'doom-debug-variables #'doom--watch-debug-vars-h) (remove-variable-watcher 'doom-debug-variables #'doom-debug--watch-vars-h)
(remove-hook 'after-load-functions #'doom--watch-debug-vars-h) (remove-hook 'after-load-functions #'doom-debug--watch-vars-h)
(message "Debug mode disabled!"))))) (message "Debug mode disabled!")))))