Refactor doom-debug-mode
+ Add explain-pause-mode + Now reloads itself if doom-debug-variables is changed or when one of its variables becomes available. + doom-debug-variables now supports a cons cell entry where its CAR is the name of the variable and CDR is the value it should be set to when doom-debug-mode is active.
This commit is contained in:
parent
70148bbfc8
commit
4e82ee4397
6 changed files with 61 additions and 14 deletions
|
@ -5,26 +5,62 @@
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defvar doom-debug-variables
|
(defvar doom-debug-variables
|
||||||
'(doom-debug-p
|
'(debug-on-error
|
||||||
init-file-debug
|
doom-debug-p
|
||||||
debug-on-error
|
|
||||||
garbage-collection-messages
|
garbage-collection-messages
|
||||||
use-package-verbose
|
|
||||||
jka-compr-verbose
|
|
||||||
lsp-log-io
|
|
||||||
gcmh-verbose
|
gcmh-verbose
|
||||||
magit-refresh-verbose
|
init-file-debug
|
||||||
url-debug)
|
jka-compr-verbose
|
||||||
"A list of variable to toggle on `doom-debug-mode'.")
|
url-debug
|
||||||
|
use-package-verbose)
|
||||||
|
"A list of variable to toggle on `doom-debug-mode'.
|
||||||
|
|
||||||
|
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.")
|
||||||
|
|
||||||
|
(defvar doom--debug-vars-old-values nil)
|
||||||
|
(defvar doom--debug-vars-undefined nil)
|
||||||
|
|
||||||
|
(defun doom--watch-debug-vars-h (&rest _)
|
||||||
|
(when-let (bound-vars (cl-remove-if-not #'boundp doom--debug-vars-undefined))
|
||||||
|
(doom-log "New variables available: %s" bound-vars)
|
||||||
|
(let ((message-log-max nil))
|
||||||
|
(doom-debug-mode -1)
|
||||||
|
(doom-debug-mode +1))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-minor-mode doom-debug-mode
|
(define-minor-mode doom-debug-mode
|
||||||
"Toggle `debug-on-error' and `doom-debug-p' for verbose logging."
|
"Toggle `debug-on-error' and `doom-debug-p' for verbose logging."
|
||||||
:init-value nil
|
:init-value nil
|
||||||
:global t
|
:global t
|
||||||
(let ((value doom-debug-mode))
|
(let ((enabled doom-debug-mode))
|
||||||
(mapc (doom-rpartial #'set value) doom-debug-variables)
|
(setq doom--debug-vars-undefined nil)
|
||||||
(message "Debug mode %s" (if value "on" "off"))))
|
(dolist (var doom-debug-variables)
|
||||||
|
(cond ((listp var)
|
||||||
|
(cl-destructuring-bind (var . val) var
|
||||||
|
(if (not (boundp var))
|
||||||
|
(add-to-list 'doom--debug-vars-undefined var)
|
||||||
|
(set-default
|
||||||
|
var (if (not enabled)
|
||||||
|
(alist-get var doom--debug-vars-old-values)
|
||||||
|
(setf (alist-get var doom--debug-vars-old-values)
|
||||||
|
(symbol-value var))
|
||||||
|
val)))))
|
||||||
|
((if (boundp var)
|
||||||
|
(set-default var enabled)
|
||||||
|
(add-to-list 'doom--debug-vars-undefined var)))))
|
||||||
|
(when (fboundp 'explain-pause-mode)
|
||||||
|
(explain-pause-mode enabled))
|
||||||
|
;; Watch for changes in `doom-debug-variables', or when packages load (and
|
||||||
|
;; potentially define one of `doom-debug-variables'), in case some of them
|
||||||
|
;; aren't defined when `doom-debug-mode' is first loaded.
|
||||||
|
(cond (enabled
|
||||||
|
(add-variable-watcher 'doom-debug-variables #'doom--watch-debug-vars-h)
|
||||||
|
(add-hook 'after-load-functions #'doom--watch-debug-vars-h))
|
||||||
|
(t
|
||||||
|
(remove-variable-watcher 'doom-debug-variables #'doom--watch-debug-vars-h)
|
||||||
|
(remove-hook 'after-load-functions #'doom--watch-debug-vars-h)))
|
||||||
|
(message "Debug mode %s" (if enabled "on" "off"))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
;; core.el
|
;; core.el
|
||||||
(package! auto-minor-mode :pin "17cfa1b54800fdef2975c0c0531dad34846a5065")
|
(package! auto-minor-mode :pin "17cfa1b54800fdef2975c0c0531dad34846a5065")
|
||||||
(package! gcmh :pin "b1bde5089169a74f62033d027e06e98cbeedd43f")
|
(package! gcmh :pin "b1bde5089169a74f62033d027e06e98cbeedd43f")
|
||||||
|
(package! explain-pause-mode
|
||||||
|
:recipe (:host github
|
||||||
|
:repo "lastquestion/explain-pause-mode")
|
||||||
|
:pin "2356c8c3639cbeeb9751744dbe737267849b4b51")
|
||||||
|
|
||||||
;; core-packages.el
|
;; core-packages.el
|
||||||
(package! straight
|
(package! straight
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#'yas-minor-mode-on)
|
#'yas-minor-mode-on)
|
||||||
|
|
||||||
:config
|
:config
|
||||||
|
(add-to-list 'doom-debug-variables '(yas-verbosity . 3))
|
||||||
|
|
||||||
;; Allow private snippets in DOOMDIR/snippets
|
;; Allow private snippets in DOOMDIR/snippets
|
||||||
(add-to-list 'yas-snippet-dirs '+snippets-dir)
|
(add-to-list 'yas-snippet-dirs '+snippets-dir)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
;;; tools/lsp/+eglot.el -*- lexical-binding: t; -*-
|
;;; tools/lsp/+eglot.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; TODO set eglot-events-buffer-size to nil in doom-debug-mode
|
|
||||||
|
|
||||||
(use-package! eglot
|
(use-package! eglot
|
||||||
:commands eglot eglot-ensure
|
:commands eglot eglot-ensure
|
||||||
:hook (eglot-managed-mode . +lsp-init-optimizations-h)
|
:hook (eglot-managed-mode . +lsp-init-optimizations-h)
|
||||||
|
@ -20,6 +18,9 @@
|
||||||
:implementations #'eglot-find-implementation
|
:implementations #'eglot-find-implementation
|
||||||
:type-definition #'eglot-find-typeDefinition
|
:type-definition #'eglot-find-typeDefinition
|
||||||
:documentation #'+eglot-lookup-documentation)
|
:documentation #'+eglot-lookup-documentation)
|
||||||
|
|
||||||
|
(add-to-list 'doom-debug-variables '(eglot-events-buffer-size . 0))
|
||||||
|
|
||||||
(when (featurep! :checkers syntax)
|
(when (featurep! :checkers syntax)
|
||||||
(after! flycheck
|
(after! flycheck
|
||||||
(load! "autoload/flycheck-eglot")))
|
(load! "autoload/flycheck-eglot")))
|
||||||
|
|
|
@ -44,6 +44,8 @@ should be a deliberate act (as is flipping this variable).")
|
||||||
lsp-enable-on-type-formatting nil)
|
lsp-enable-on-type-formatting nil)
|
||||||
|
|
||||||
:config
|
:config
|
||||||
|
(pushnew! doom-debug-variables 'lsp-log-io 'lsp-print-performance)
|
||||||
|
|
||||||
(setq lsp-intelephense-storage-path (concat doom-cache-dir "lsp-intelephense/")
|
(setq lsp-intelephense-storage-path (concat doom-cache-dir "lsp-intelephense/")
|
||||||
lsp-vetur-global-snippets-dir (expand-file-name "vetur"
|
lsp-vetur-global-snippets-dir (expand-file-name "vetur"
|
||||||
(or (bound-and-true-p +snippets-dir)
|
(or (bound-and-true-p +snippets-dir)
|
||||||
|
|
|
@ -18,6 +18,8 @@ For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.")
|
||||||
transient-values-file (concat doom-etc-dir "transient/values")
|
transient-values-file (concat doom-etc-dir "transient/values")
|
||||||
transient-history-file (concat doom-etc-dir "transient/history"))
|
transient-history-file (concat doom-etc-dir "transient/history"))
|
||||||
:config
|
:config
|
||||||
|
(add-to-list 'doom-debug-variables 'magit-refresh-verbose)
|
||||||
|
|
||||||
(setq transient-default-level 5
|
(setq transient-default-level 5
|
||||||
magit-diff-refine-hunk t ; show granular diffs in selected hunk
|
magit-diff-refine-hunk t ; show granular diffs in selected hunk
|
||||||
;; Don't autosave repo buffers. This is too magical, and saving can
|
;; Don't autosave repo buffers. This is too magical, and saving can
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue