Refactor feature/debugger (still WIP)

This commit is contained in:
Henrik Lissner 2017-09-23 14:42:04 +02:00
parent 637824e543
commit 63a4a61714
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 27 additions and 23 deletions

View file

@ -2,8 +2,10 @@
;;;###autoload ;;;###autoload
(defun +debugger/quit () (defun +debugger/quit ()
"Quit the active debugger, if any."
(interactive) (interactive)
(ignore-errors (call-interactively 'realgud:cmd-quit)) (ignore-errors (call-interactively #'realgud:cmd-quit))
(doom/popup-close) (doom/popup-close)
(evil-normal-state)) (when (featurep 'evil)
(evil-normal-state)))

View file

@ -1,29 +1,31 @@
;;; feature/debugger/autoload/evil.el -*- lexical-binding: t; -*- ;;; feature/debugger/autoload/evil.el -*- lexical-binding: t; -*-
;;;###autoload (autoload '+debugger:run "feature/debugger/autoload/evil" nil t) ;;;###autoload (autoload '+debugger:start "feature/debugger/autoload/evil" nil t)
(evil-define-command +debugger:run (&optional path) (evil-define-command +debugger:start (&optional path)
"Initiate debugger for current major mode" "Initiate debugger for current major mode"
(interactive "<f>") (interactive "<f>")
;; TODO Add python debugging
(let ((default-directory (doom-project-root))) (let ((default-directory (doom-project-root)))
(cond ((memq major-mode '(c-mode c++-mode)) (pcase major-mode
(realgud:gdb (if path (concat "gdb " path)))) ((or 'c-mode 'c++-mode)
((memq major-mode '(ruby-mode enh-ruby-mode)) (realgud:gdb (if path (concat "gdb " path))))
(doom:repl nil (format "run '%s'" (file-name-nondirectory (or path buffer-file-name))))) ((or 'ruby-mode 'enh-ruby-mode)
((eq major-mode 'sh-mode) ;; FIXME
(let ((shell sh-shell)) (doom:repl nil (format "run '%s'" (file-name-nondirectory (or path buffer-file-name)))))
(when (string= shell "sh") ('sh-mode
(setq shell "bash")) (let ((shell sh-shell))
(cond ((string= shell "bash") (when (string= shell "sh")
(realgud:bashdb (if path (concat "bashdb " path)))) (setq shell "bash"))
((string= shell "zsh") (pcase shell
(realgud:zshdb (if path (concat "zshdb " path)))) ("bash"
(t (user-error "No shell debugger for %s" shell))))) (realgud:bashdb (if path (concat "bashdb " path))))
;; TODO Add python debugging ("zsh"
((memq major-mode '(js-mode js2-mode js3-mode)) (realgud:zshdb (if path (concat "zshdb " path))))
(realgud:trepanjs)) (_ (user-error "No shell debugger for %s" shell)))))
((eq major-mode 'haskell-mode) ((or 'js-mode 'js2-mode 'js3-mode)
(haskell-debug)) (realgud:trepanjs))
(t (user-error "No debugger for %s" major-mode))))) ('haskell-mode (haskell-debug))
(_ (user-error "No debugger for %s" major-mode)))))
;;;###autoload (autoload '+debugger:toggle-breakpoint "feature/debugger/autoload/evil" nil t) ;;;###autoload (autoload '+debugger:toggle-breakpoint "feature/debugger/autoload/evil" nil t)
(evil-define-command +debugger:toggle-breakpoint (&optional bang) (evil-define-command +debugger:toggle-breakpoint (&optional bang)