From ccb62321d234993a66287c4e1a3cfdea63d140ff Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Tue, 29 Aug 2023 17:02:40 -0700 Subject: Fix handling of Eshell debug modes Previously, these were enabled/disabled at byte-compilation time, but we want to control them at runtime. * lisp/eshell/esh-cmd.el (eshell-eval-command): Call 'eshell-debug-command-start'. (eshell-manipulate): Check 'eshell-debug-command' at runtime. Update callers. (eshell-debug-command): Move to "esh-util.el". (eshell/eshell-debug, pcomplate/eshell-mode/eshell-debug): Move to "em-basic.el". (eshell-debug-show-parsed-args): Update implementation. * lisp/eshell/esh-util.el (eshell-debug-command): Move from "esh-cmd.el" and convert to a list. (eshell-debug-command-buffer): New variable. (eshell-condition-case): Check 'eshell-handle-errors' at runtime. (eshell-debug-command-start): New function. (eshell-debug-command): Move from "esh-cmd.el" and convert to a macro. * lisp/eshell/em-basic.el (eshell/eshell-debug) (pcomplete/eshell-mode/eshell-debug): Move from "esh-cmd.el" and reimplement. * lisp/eshell/eshell.el (eshell-command): Pass the original input to 'eshell-eval-command'. * doc/misc/eshell.texi (Built-ins): Update documentation for 'eshell-debug'. --- lisp/eshell/em-basic.el | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lisp/eshell/em-basic.el') diff --git a/lisp/eshell/em-basic.el b/lisp/eshell/em-basic.el index 016afe811b2..554ee83b015 100644 --- a/lisp/eshell/em-basic.el +++ b/lisp/eshell/em-basic.el @@ -188,6 +188,37 @@ or `eshell-printn' for display." (put 'eshell/umask 'eshell-no-numeric-conversions t) +(defun eshell/eshell-debug (&rest args) + "A command for toggling certain debug variables." + (eshell-eval-using-options + "eshell-debug" args + '((?h "help" nil nil "display this usage message") + :usage "[KIND]... +This command is used to aid in debugging problems related to Eshell +itself. It is not useful for anything else. The recognized `kinds' +are: + + error stops Eshell from trapping errors + form shows command form manipulation in `*eshell last cmd*'") + (if args + (dolist (kind args) + (if (equal kind "error") + (setq eshell-handle-errors (not eshell-handle-errors)) + (let ((kind-sym (intern kind))) + (if (memq kind-sym eshell-debug-command) + (setq eshell-debug-command + (delq kind-sym eshell-debug-command)) + (push kind-sym eshell-debug-command))))) + ;; Output the currently-enabled debug kinds. + (unless eshell-handle-errors + (eshell-print "errors\n")) + (dolist (kind eshell-debug-command) + (eshell-printn (symbol-name kind)))))) + +(defun pcomplete/eshell-mode/eshell-debug () + "Completion for the `debug' command." + (while (pcomplete-here '("error" "form")))) + (provide 'em-basic) ;; Local Variables: -- cgit v1.2.1