Refactor debug segment.

This commit is contained in:
Vincent Zhang 2019-06-24 14:13:08 +08:00
parent 34b23b3e25
commit 7a29c27b55

View file

@ -1858,26 +1858,12 @@ mouse-3: Fetch notifications"
:face face) :face face)
(propertize "!" 'face face))) (propertize "!" 'face face)))
(doom-modeline-def-segment debug (defsubst doom-modeline--debug-dap ()
"The current debug state." "The current `dap-mode' 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) (when (and (bound-and-true-p dap-mode)
(bound-and-true-p lsp-mode) (bound-and-true-p lsp-mode)
(dap--cur-session)) (dap--cur-session))
(concat (propertize (doom-modeline-debug-icon 'doom-modeline-warning)
(propertize
(doom-modeline-debug-icon 'doom-modeline-warning)
'help-echo (format "DAP (%s) 'help-echo (format "DAP (%s)
mouse-1: Display debug hydra mouse-1: Display debug hydra
mouse-2: Display recent configurations mouse-2: Display recent configurations
@ -1891,15 +1877,13 @@ mouse-3: Disconnect session"
#'dap-debug-recent) #'dap-debug-recent)
(define-key map [mode-line mouse-3] (define-key map [mode-line mouse-3]
#'dap-disconnect) #'dap-disconnect)
map)) map))))
(doom-modeline-vspc)))
;; For `edebug' (defsubst doom-modeline--debug-edebug ()
"The current `edebug' state."
(when (or (bound-and-true-p edebug-mode) (when (or (bound-and-true-p edebug-mode)
(bound-and-true-p edebug-x-mode)) (bound-and-true-p edebug-x-mode))
(concat (propertize (doom-modeline-debug-icon 'doom-modeline-warning)
(propertize
(doom-modeline-debug-icon 'doom-modeline-warning)
'help-echo (format "EDebug (%s) 'help-echo (format "EDebug (%s)
mouse-1: Show help mouse-1: Show help
mouse-2: Next mouse-2: Next
@ -1913,36 +1897,41 @@ mouse-3: Stop debugging"
#'edebug-next-mode) #'edebug-next-mode)
(define-key map [mode-line mouse-3] (define-key map [mode-line mouse-3]
#'edebug-stop) #'edebug-stop)
map)) map))))
(doom-modeline-vspc)))
;; For `debug-on-error' (defsubst doom-modeline--debug-on-error ()
"The current `debug-on-error' state."
(when debug-on-error (when debug-on-error
(concat
(propertize (doom-modeline-debug-icon 'doom-modeline-urgent) (propertize (doom-modeline-debug-icon 'doom-modeline-urgent)
'help-echo "Debug on Error 'help-echo "Debug on Error
mouse-1: Toggle Debug on Error" mouse-1: Toggle Debug on Error"
'mouse-face '(:box 0) 'mouse-face '(:box 0)
'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-error)) 'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-error))))
(doom-modeline-vspc)))
;; For `debug-on-quit' (defsubst doom-modeline--debug-on-quit ()
"The current `debug-on-quit' state."
(when debug-on-quit (when debug-on-quit
(propertize (propertize (doom-modeline-debug-icon 'doom-modeline-buffer-path)
(doom-modeline-debug-icon 'doom-modeline-buffer-path)
'help-echo "Debug on Quit 'help-echo "Debug on Quit
mouse-1: Toggle Debug on Quit" mouse-1: Toggle Debug on Quit"
'mouse-face '(:box 0) 'mouse-face '(:box 0)
'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-quit))) 'local-map (make-mode-line-mouse-map 'mouse-1 #'toggle-debug-on-quit))))
(when (or (and (bound-and-true-p dap-mode) (doom-modeline-def-segment debug
(bound-and-true-p lsp-mode) "The current debug state."
(dap--cur-session)) (when (doom-modeline--active)
(bound-and-true-p edebug-mode) (let* ((dap (doom-modeline--debug-dap))
(bound-and-true-p edebug-x-mode) (edebug (doom-modeline--debug-edebug))
debug-on-error (on-error (doom-modeline--debug-on-error))
debug-on-quit) (on-quit (doom-modeline--debug-on-quit))
(doom-modeline-spc))))) (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))))
;; ;;