mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Refactor debug segment.
This commit is contained in:
parent
34b23b3e25
commit
7a29c27b55
1 changed files with 62 additions and 73 deletions
|
@ -1858,91 +1858,80 @@ mouse-3: Fetch notifications"
|
|||
:face face)
|
||||
(propertize "!" 'face face)))
|
||||
|
||||
(doom-modeline-def-segment debug
|
||||
"The current debug state."
|
||||
(when (doom-modeline--active)
|
||||
(concat
|
||||
(when (or (and (bound-and-true-p dap-mode)
|
||||
(bound-and-true-p lsp-mode)
|
||||
(dap--cur-session))
|
||||
(bound-and-true-p edebug-mode)
|
||||
(bound-and-true-p edebug-x-mode)
|
||||
debug-on-error
|
||||
debug-on-quit)
|
||||
(doom-modeline-spc))
|
||||
|
||||
;; For `dap-mode'
|
||||
(when (and (bound-and-true-p dap-mode)
|
||||
(bound-and-true-p lsp-mode)
|
||||
(dap--cur-session))
|
||||
(concat
|
||||
(propertize
|
||||
(doom-modeline-debug-icon 'doom-modeline-warning)
|
||||
'help-echo (format "DAP (%s)
|
||||
(defsubst doom-modeline--debug-dap ()
|
||||
"The current `dap-mode' state."
|
||||
(when (and (bound-and-true-p dap-mode)
|
||||
(bound-and-true-p lsp-mode)
|
||||
(dap--cur-session))
|
||||
(propertize (doom-modeline-debug-icon 'doom-modeline-warning)
|
||||
'help-echo (format "DAP (%s)
|
||||
mouse-1: Display debug hydra
|
||||
mouse-2: Display recent configurations
|
||||
mouse-3: Disconnect session"
|
||||
(dap-mode-line))
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (let ((map (make-sparse-keymap)))
|
||||
(define-key map [mode-line mouse-1]
|
||||
#'dap-hydra)
|
||||
(define-key map [mode-line mouse-2]
|
||||
#'dap-debug-recent)
|
||||
(define-key map [mode-line mouse-3]
|
||||
#'dap-disconnect)
|
||||
map))
|
||||
(doom-modeline-vspc)))
|
||||
(dap-mode-line))
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (let ((map (make-sparse-keymap)))
|
||||
(define-key map [mode-line mouse-1]
|
||||
#'dap-hydra)
|
||||
(define-key map [mode-line mouse-2]
|
||||
#'dap-debug-recent)
|
||||
(define-key map [mode-line mouse-3]
|
||||
#'dap-disconnect)
|
||||
map))))
|
||||
|
||||
;; For `edebug'
|
||||
(when (or (bound-and-true-p edebug-mode)
|
||||
(bound-and-true-p edebug-x-mode))
|
||||
(concat
|
||||
(propertize
|
||||
(doom-modeline-debug-icon 'doom-modeline-warning)
|
||||
'help-echo (format "EDebug (%s)
|
||||
(defsubst doom-modeline--debug-edebug ()
|
||||
"The current `edebug' state."
|
||||
(when (or (bound-and-true-p edebug-mode)
|
||||
(bound-and-true-p edebug-x-mode))
|
||||
(propertize (doom-modeline-debug-icon 'doom-modeline-warning)
|
||||
'help-echo (format "EDebug (%s)
|
||||
mouse-1: Show help
|
||||
mouse-2: Next
|
||||
mouse-3: Stop debugging"
|
||||
edebug-execution-mode)
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (let ((map (make-sparse-keymap)))
|
||||
(define-key map [mode-line mouse-1]
|
||||
#'edebug-help)
|
||||
(define-key map [mode-line mouse-2]
|
||||
#'edebug-next-mode)
|
||||
(define-key map [mode-line mouse-3]
|
||||
#'edebug-stop)
|
||||
map))
|
||||
(doom-modeline-vspc)))
|
||||
edebug-execution-mode)
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (let ((map (make-sparse-keymap)))
|
||||
(define-key map [mode-line mouse-1]
|
||||
#'edebug-help)
|
||||
(define-key map [mode-line mouse-2]
|
||||
#'edebug-next-mode)
|
||||
(define-key map [mode-line mouse-3]
|
||||
#'edebug-stop)
|
||||
map))))
|
||||
|
||||
;; For `debug-on-error'
|
||||
(when debug-on-error
|
||||
(concat
|
||||
(propertize (doom-modeline-debug-icon 'doom-modeline-urgent)
|
||||
'help-echo "Debug on Error
|
||||
(defsubst doom-modeline--debug-on-error ()
|
||||
"The current `debug-on-error' state."
|
||||
(when debug-on-error
|
||||
(propertize (doom-modeline-debug-icon 'doom-modeline-urgent)
|
||||
'help-echo "Debug on Error
|
||||
mouse-1: Toggle Debug on Error"
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-error))
|
||||
(doom-modeline-vspc)))
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-error))))
|
||||
|
||||
;; For `debug-on-quit'
|
||||
(when debug-on-quit
|
||||
(propertize
|
||||
(doom-modeline-debug-icon 'doom-modeline-buffer-path)
|
||||
'help-echo "Debug on Quit
|
||||
(defsubst doom-modeline--debug-on-quit ()
|
||||
"The current `debug-on-quit' state."
|
||||
(when debug-on-quit
|
||||
(propertize (doom-modeline-debug-icon 'doom-modeline-buffer-path)
|
||||
'help-echo "Debug on Quit
|
||||
mouse-1: Toggle Debug on Quit"
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-quit)))
|
||||
'mouse-face '(:box 0)
|
||||
'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-quit))))
|
||||
|
||||
(when (or (and (bound-and-true-p dap-mode)
|
||||
(bound-and-true-p lsp-mode)
|
||||
(dap--cur-session))
|
||||
(bound-and-true-p edebug-mode)
|
||||
(bound-and-true-p edebug-x-mode)
|
||||
debug-on-error
|
||||
debug-on-quit)
|
||||
(doom-modeline-spc)))))
|
||||
(doom-modeline-def-segment debug
|
||||
"The current debug state."
|
||||
(when (doom-modeline--active)
|
||||
(let* ((dap (doom-modeline--debug-dap))
|
||||
(edebug (doom-modeline--debug-edebug))
|
||||
(on-error (doom-modeline--debug-on-error))
|
||||
(on-quit (doom-modeline--debug-on-quit))
|
||||
(splitter (and (or dap edebug on-error on-quit) (doom-modeline-spc))))
|
||||
(concat
|
||||
splitter
|
||||
(when dap (concat dap (doom-modeline-vspc)))
|
||||
(when edebug (concat edebug (doom-modeline-vspc)))
|
||||
(when on-error (concat on-error (doom-modeline-vspc)))
|
||||
on-quit
|
||||
splitter))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue