+ enable lexical-scope everywhere (lexical-binding = t): ~5-10% faster startup; ~5-20% general boost + reduce consing, function calls & garbage collection by preferring cl-loop & dolist over lambda closures (for mapc[ar], add-hook, and various cl-lib filter/map/reduce functions) -- where possible + prefer functions with dedicated opcodes, like assq (see byte-defop's in bytecomp.el for more) + prefer pcase & cond (faster) over cl-case + general refactor for code readability + ensure naming & style conventions are adhered to + appease byte-compiler by marking unused variables with underscore + defer minor mode activation to after-init, emacs-startup or window-setup hooks; a customization opportunity for users + ensures custom functionality won't interfere with startup.
31 lines
1.5 KiB
EmacsLisp
31 lines
1.5 KiB
EmacsLisp
;;; feature/debug/autoload/evil.el -*- lexical-binding: t; -*-
|
|
|
|
;;;###autoload (autoload '+debug:run "feature/debug/autoload/evil" nil t)
|
|
(evil-define-command +debug:run (&optional path)
|
|
"Initiate debugger for current major mode"
|
|
(interactive "<f>")
|
|
(let ((default-directory (doom-project-root)))
|
|
(cond ((memq major-mode '(c-mode c++-mode))
|
|
(realgud:gdb (if path (concat "gdb " path))))
|
|
((memq major-mode '(ruby-mode enh-ruby-mode))
|
|
(doom:repl nil (format "run '%s'" (file-name-nondirectory (or path buffer-file-name)))))
|
|
((eq major-mode 'sh-mode)
|
|
(let ((shell sh-shell))
|
|
(when (string= shell "sh")
|
|
(setq shell "bash"))
|
|
(cond ((string= shell "bash")
|
|
(realgud:bashdb (if path (concat "bashdb " path))))
|
|
((string= shell "zsh")
|
|
(realgud:zshdb (if path (concat "zshdb " path))))
|
|
(t (user-error "No shell debugger for %s" shell)))))
|
|
;; TODO Add python debugging
|
|
((memq major-mode '(js-mode js2-mode js3-mode))
|
|
(realgud:trepanjs))
|
|
((eq major-mode 'haskell-mode)
|
|
(haskell-debug))
|
|
(t (user-error "No debugger for %s" major-mode)))))
|
|
|
|
;;;###autoload (autoload '+debug:toggle-breakpoint "feature/debug/autoload/evil" nil t)
|
|
(evil-define-command +debug:toggle-breakpoint (&optional bang)
|
|
(interactive "<!>")
|
|
(call-interactively (if bang 'realgud:cmd-clear 'realgud:cmd-break)))
|