Optimize debug segment.

This commit is contained in:
Vincent Zhang 2019-06-23 23:48:24 +08:00
parent 1a77ba0690
commit 34b23b3e25

View file

@ -1862,59 +1862,69 @@ mouse-3: Fetch notifications"
"The current debug state." "The current debug state."
(when (doom-modeline--active) (when (doom-modeline--active)
(concat (concat
(and (or debug-on-error debug-on-quit (when (or (and (bound-and-true-p dap-mode)
(bound-and-true-p edebug-mode) (bound-and-true-p lsp-mode)
(bound-and-true-p edebug-x-mode)) (dap--cur-session))
(doom-modeline-spc)) (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' ;; 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))
(propertize (concat
(doom-modeline-debug-icon 'doom-modeline-warning) (propertize
'help-echo (format "DAP (%s) (doom-modeline-debug-icon 'doom-modeline-warning)
'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
mouse-3: Disconnect session" mouse-3: Disconnect session"
(dap-mode-line)) (dap-mode-line))
'mouse-face '(:box 0) 'mouse-face '(:box 0)
'local-map (let ((map (make-sparse-keymap))) 'local-map (let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1] (define-key map [mode-line mouse-1]
#'dap-hydra) #'dap-hydra)
(define-key map [mode-line mouse-2] (define-key map [mode-line mouse-2]
#'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' ;; For `edebug'
(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))
(propertize (concat
(doom-modeline-debug-icon 'doom-modeline-warning) (propertize
'help-echo (format "EDebug (%s) (doom-modeline-debug-icon 'doom-modeline-warning)
'help-echo (format "EDebug (%s)
mouse-1: Show help mouse-1: Show help
mouse-2: Next mouse-2: Next
mouse-3: Stop debugging" mouse-3: Stop debugging"
edebug-execution-mode) edebug-execution-mode)
'mouse-face '(:box 0) 'mouse-face '(:box 0)
'local-map (let ((map (make-sparse-keymap))) 'local-map (let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1] (define-key map [mode-line mouse-1]
#'edebug-help) #'edebug-help)
(define-key map [mode-line mouse-2] (define-key map [mode-line mouse-2]
#'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' ;; For `debug-on-error'
(when debug-on-error (when debug-on-error
(propertize (doom-modeline-debug-icon 'doom-modeline-urgent) (concat
'help-echo "Debug on Error (propertize (doom-modeline-debug-icon 'doom-modeline-urgent)
'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' ;; For `debug-on-quit'
(when debug-on-quit (when debug-on-quit
@ -1925,10 +1935,14 @@ 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)))
(and (or debug-on-error debug-on-quit (when (or (and (bound-and-true-p dap-mode)
(bound-and-true-p edebug-mode) (bound-and-true-p lsp-mode)
(bound-and-true-p edebug-x-mode)) (dap--cur-session))
(doom-modeline-spc))))) (bound-and-true-p edebug-mode)
(bound-and-true-p edebug-x-mode)
debug-on-error
debug-on-quit)
(doom-modeline-spc)))))
;; ;;