[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 81f0b58 172/215: Merge pull request #114 from rocky/defaul
From: |
Rocky Bernstein |
Subject: |
[elpa] master 81f0b58 172/215: Merge pull request #114 from rocky/default-hash |
Date: |
Sat, 30 Jul 2016 14:49:03 +0000 (UTC) |
branch: master
commit 81f0b582cdf3bd77d09daaf4bc05842b9f1433b6
Merge: 1c3d8c2 4cdbc0e
Author: R. Bernstein <address@hidden>
Commit: R. Bernstein <address@hidden>
Merge pull request #114 from rocky/default-hash
Further refactor cmds.el
---
realgud/common/cmds.el | 147 ++++++++++++++++++++++++++++--------------------
1 file changed, 85 insertions(+), 62 deletions(-)
diff --git a/realgud/common/cmds.el b/realgud/common/cmds.el
index ca83a1c..38cb0fc 100644
--- a/realgud/common/cmds.el
+++ b/realgud/common/cmds.el
@@ -51,27 +51,54 @@ when command was run from a menu."
t)
t))
-(defun realgud:cmd-run-command(arg cmd-name default-cmd-template
- &optional no-record? frame-switch?
- realgud-prompts?)
- "Run debugger command CMD-NAME using DEFAULT-CMD-TEMPLATE
-if none has been set in the command hash. If key is given we'll set
-a shortcut for that key."
- (let ((buffer (current-buffer))
- (cmdbuf (realgud-get-cmdbuf))
- (cmd-hash)
- (cmd)
- )
- (with-current-buffer-safe cmdbuf
- (realgud-cmdbuf-info-in-srcbuf?= (not (realgud-cmdbuf? buffer)))
- (setq cmd-hash (realgud-cmdbuf-info-cmd-hash realgud-cmdbuf-info))
- (unless (and cmd-hash (setq cmd (gethash cmd-name cmd-hash)))
- (setq cmd default-cmd-template))
- )
- (if (equal cmd "*not-implemented*")
+(defconst realgud-cmd:default-hash
+ (let ((hash (make-hash-table :test 'equal)))
+ (puthash "backtrace" "backtrace" hash)
+ (puthash "break" "break %X:%l" hash)
+ (puthash "clear" "clear %l" hash)
+ (puthash "continue" "continue" hash)
+ (puthash "delete" "delete %p" hash)
+ (puthash "disable" "disable %p" hash)
+ (puthash "down" "down %p" hash)
+ (puthash "enable" "enable %p" hash)
+ (puthash "eval" "eval %s" hash)
+ (puthash "finish" "finish" hash)
+ (puthash "frame" "frame %p" hash)
+ (puthash "kill" "kill" hash)
+ (puthash "next" "next %p" hash)
+ (puthash "repeat-last" "\n" hash)
+ (puthash "restart" "run" hash)
+ (puthash "shell" "shell" hash)
+ (puthash "step" "step %p" hash)
+ (puthash "until" "until" hash)
+ (puthash "up" "up %p" hash)
+ hash)
+ "Default hash of command name → debugger command.
+This is used as a fallback when the debugger-specific command
+hash does not specify a custom debugger command.")
+
+(defun realgud:cmd-run-command(arg cmd-name &optional
+ default-cmd-template no-record?
+ frame-switch? realgud-prompts?)
+ "Run debugger command CMD-NAME.
+If CMD-NAME isn't set in the command buffer's command hash, use
+DEFAULT-CMD-TEMPLATE and fall back to looking CMD-NAME up in
+`realgud:cmd-get-cmd-hash'."
+ (let* ((buffer (current-buffer))
+ (cmdbuf (realgud-get-cmdbuf))
+ (cmd-hash (with-current-buffer-safe cmdbuf
+ (realgud-cmdbuf-info-cmd-hash realgud-cmdbuf-info)))
+ (cmd (or (and (hash-table-p cmd-hash)
+ (gethash cmd-name cmd-hash))
+ default-cmd-template
+ (gethash cmd-name realgud-cmd:default-hash))))
+ (if (or (null cmd) (equal cmd "*not-implemented*"))
(message "Command %s is not implemented for this debugger" cmd-name)
- ;; else
(progn
+ ;; Set flag to know which buffer to jump back to
+ (with-current-buffer-safe cmdbuf
+ (realgud-cmdbuf-info-in-srcbuf?= (not (realgud-cmdbuf? buffer))))
+ ;; Run actual command
(realgud-command cmd arg no-record? frame-switch? realgud-prompts?)
;; FIXME: Figure out how to update the position if the source
;; buffer is displayed.
@@ -103,18 +130,18 @@ as in `realgud:cmd-run-command'."
(defun realgud:cmd-backtrace(arg)
"Show the current call stack"
(interactive "p")
- (realgud:cmd-run-command arg "backtrace" "backtrace")
+ (realgud:cmd-run-command arg "backtrace")
)
(defun realgud:cmd-break(arg)
"Set a breakpoint at the current line"
(interactive "p")
- (realgud:cmd-run-command arg "break" "break %X:%l"))
+ (realgud:cmd-run-command arg "break"))
(defun realgud:cmd-clear(line-num)
"Delete breakpoint at the current line"
(interactive "p")
- (realgud:cmd-run-command line-num "clear" "clear %l"))
+ (realgud:cmd-run-command line-num "clear"))
(defun realgud:cmd-continue(&optional arg)
"Continue execution.
@@ -125,7 +152,7 @@ running."
(list (read-string "Continue args: " nil nil nil t))))
(when (or arg (realgud:prompt-if-safe-mode
"Continue to next breakpoint?"))
- (realgud:cmd-run-command arg "continue" "continue")))
+ (realgud:cmd-run-command arg "continue")))
(defun realgud:bpnum-on-current-line()
"Return number of one breakpoint on current line, if any.
@@ -153,7 +180,7 @@ numeric prefix argument, delete breakpoint with that number
instead. With prefix argument (C-u), or when no breakpoint can
be found on the current line, prompt for a breakpoint number."
(interactive (realgud:bpnum-from-prefix-arg))
- (realgud:cmd-run-command bpnum "delete" "delete %p"))
+ (realgud:cmd-run-command bpnum "delete"))
(defun realgud:cmd-disable(bpnum)
"Disable breakpoint BPNUM.
@@ -162,7 +189,7 @@ numeric prefix argument, disable breakpoint with that number
instead. With prefix argument (C-u), or when no breakpoint can
be found on the current line, prompt for a breakpoint number."
(interactive (realgud:bpnum-from-prefix-arg))
- (realgud:cmd-run-command bpnum "disable" "disable %p"))
+ (realgud:cmd-run-command bpnum "disable"))
(defun realgud:cmd-enable(bpnum)
"Enable breakpoint BPNUM.
@@ -171,7 +198,7 @@ numeric prefix argument, enable breakpoint with that number
instead. With prefix argument (C-u), or when no breakpoint can
be found on the current line, prompt for a breakpoint number."
(interactive (realgud:bpnum-from-prefix-arg))
- (realgud:cmd-run-command bpnum "enable" "enable %p"))
+ (realgud:cmd-run-command bpnum "enable"))
(defun realgud-cmds--add-remove-bp (pos)
"Add or delete breakpoint at POS."
@@ -195,14 +222,14 @@ EVENT should be a mouse click on the left fringe or
margin."
(defun realgud:cmd-eval(arg)
"Evaluate an expression."
(interactive "MEval expesssion: ")
- (realgud:cmd-run-command arg "eval" "eval %s")
+ (realgud:cmd-run-command arg "eval")
)
(defun realgud:cmd-eval-region(start end)
"Evaluate current region."
(interactive "r")
(let ((text (buffer-substring-no-properties start end)))
- (realgud:cmd-run-command text "eval" "eval %s")))
+ (realgud:cmd-run-command text "eval")))
(defun realgud:cmd-eval-dwim()
"Eval the current region if active; otherwise, prompt."
@@ -217,42 +244,41 @@ EVENT should be a mouse click on the left fringe or
margin."
This command is often referred to as 'step out' as opposed to
'step over' or 'step into'."
(interactive "p")
- (realgud:cmd-run-command arg "finish" "finish")
+ (realgud:cmd-run-command arg "finish")
)
(defun realgud:cmd-frame(arg)
"Change the current frame number to the value of the numeric argument.
If no argument specified use 0 or the most recent frame."
(interactive "p")
- (realgud:cmd-run-command arg "frame" "frame %p" t t)
+ (realgud:cmd-run-command arg "frame" nil t t)
)
(defun realgud:cmd-kill(arg)
"kill debugger process"
(interactive "p")
- (realgud:cmd-run-command arg "kill" "kill" nil nil t)
+ (realgud:cmd-run-command arg "kill" nil nil nil t)
)
(defun realgud:cmd-newer-frame(&optional arg)
"Move the current frame to a newer (more recent) frame.
With a numeric argument move that many levels forward."
(interactive "p")
- (realgud:cmd-run-command arg "down" "down %p" t t)
+ (realgud:cmd-run-command arg "down" nil t t)
)
-(defun realgud:cmd-next(&optional arg)
+(defun realgud:cmd-next(&optional count)
"Step one source line at current call level.
-With a numeric argument, step that many times. This command is
-often referred to as 'step through' as opposed to 'step into' or
-'step out'.
+With numeric argument COUNT, step that many times. This command is
+often referred to as `step through' as opposed to `step into' or
+`step out'.
-The definition of 'next' is debugger specific so, see the
-debugger documentation for a more complete definition of what is
-getting stepped."
+The definition of `next' is debugger specific, so see the
+documentation of your debugger for a more complete definition of
+what is getting stepped."
(interactive "p")
- (realgud:cmd-run-command arg "next" "next %p")
-)
+ (realgud:cmd-run-command count "next"))
(defun realgud:cmd-next-no-arg(&optional arg)
"Step one source line at current call level.
@@ -261,57 +287,54 @@ The definition of 'next' is debugger specific so, see the
debugger documentation for a more complete definition of what is
getting stepped."
(interactive)
- (realgud:cmd-run-command nil "next" "next")
-)
+ (realgud:cmd-next))
(defun realgud:cmd-older-frame(&optional arg)
"Move the current frame to an older (less recent) frame.
With a numeric argument move that many levels back."
(interactive "p")
- (realgud:cmd-run-command arg "up" "up %p" t t)
+ (realgud:cmd-run-command arg "up" nil t t)
)
(defun realgud:cmd-repeat-last(&optional arg)
"Repeat the last command (or generally what <enter> does."
(interactive "")
- (realgud:cmd-run-command arg "repeat-last" "\n" t nil t)
+ (realgud:cmd-run-command arg "repeat-last" nil t nil t)
)
(defun realgud:cmd-restart(&optional arg)
"Restart execution."
(interactive "")
- (realgud:cmd-run-command arg "restart" "run" t nil t)
+ (realgud:cmd-run-command arg "restart" nil t nil t)
)
(defun realgud:cmd-shell(&optional arg)
"Drop to a shell."
(interactive "")
- (realgud:cmd-run-command arg "shell" "shell")
+ (realgud:cmd-run-command arg "shell")
)
-(defun realgud:cmd-step(&optional arg)
+(defun realgud:cmd-step(&optional count)
"Step one source line.
-With a numeric argument, step that many times.
-This command is often referred to as 'step into' as opposed to
-'step over' or 'step out'.
+With a numeric prefix argument COUNT, step that many times.
+This command is often referred to as `step into' as opposed to
+`step over' or `step out'.
-The definition of 'step' is debugger specific so, see the
-debugger documentation for a more complete definition of what is
-getting stepped."
+The definition of `step' is debugger specific, so see the
+documentation of your debugger for a more complete definition of
+what is getting stepped."
(interactive "p")
- (realgud:cmd-run-command arg "step" "step %p")
-)
+ (realgud:cmd-run-command count "step"))
(defun realgud:cmd-step-no-arg()
"Step one source line.
-The definition of 'step' is debugger specific so, see the
-debugger documentation for a more complete definition of what is
-getting stepped."
+The definition of `step' is debugger specific, so see the
+documentation of your debugger for a more complete definition of
+what is getting stepped."
(interactive)
- (realgud:cmd-run-command nil "step" "step")
-)
+ (realgud:cmd-step))
(defun realgud:cmd-terminate ()
"Gently terminate source and command buffers without possibly
@@ -330,7 +353,7 @@ Continue until the current line. In some cases this is
really
two commands - setting a temporary breakpoint on the line and
continuing execution."
(interactive "p")
- (realgud:cmd-run-command arg "until" "until")
+ (realgud:cmd-run-command arg "until")
)
(defun realgud:cmd-quit (&optional arg)
- [elpa] master 8e5eaaf 128/215: Merge pull request #94 from rocky/84-fix-autoloads, (continued)
- [elpa] master 8e5eaaf 128/215: Merge pull request #94 from rocky/84-fix-autoloads, Rocky Bernstein, 2016/07/30
- [elpa] master 2c31d58 154/215: Typo, Rocky Bernstein, 2016/07/30
- [elpa] master 64bd779 155/215: Alway late on this kind of thing., Rocky Bernstein, 2016/07/30
- [elpa] master b6407b9 197/215: Merge pull request #130 from realgud/enable-disable, Rocky Bernstein, 2016/07/30
- [elpa] master 9ed122a 199/215: Correct enable/disable pattern for trepan.pl, Rocky Bernstein, 2016/07/30
- [elpa] master 392a755 083/215: Use quit! in python trepan debuggers, Rocky Bernstein, 2016/07/30
- [elpa] master 8d7961d 212/215: Need to put back el-get-install.el for travis, Rocky Bernstein, 2016/07/30
- [elpa] master e68e3a2 133/215: Add a few bindings to shortkey-mode, Rocky Bernstein, 2016/07/30
- [elpa] master 6500858 081/215: Try to tidy badges a little, Rocky Bernstein, 2016/07/30
- [elpa] master c633f3f 136/215: Ignore safe-mode setting when clicking a toolbar button, Rocky Bernstein, 2016/07/30
- [elpa] master 81f0b58 172/215: Merge pull request #114 from rocky/default-hash,
Rocky Bernstein <=
- [elpa] master d2b8d13 134/215: Remove key argument of realgud:cmd-remap, Rocky Bernstein, 2016/07/30
- [elpa] master bf1cd9f 087/215: Travis emacs doesn't do font-lock-ensure. Use older form for now, Rocky Bernstein, 2016/07/30
- [elpa] master 8e00edc 174/215: Further cleanup in cmds.el: remove unused arguments, Rocky Bernstein, 2016/07/30
- [elpa] master 6429d94 129/215: Revert "Manually generate "recursive" autoloads for subdirectories", Rocky Bernstein, 2016/07/30
- [elpa] master 1ff6720 189/215: Merge pull request #127 from realgud/quit-confirm, Rocky Bernstein, 2016/07/30
- [elpa] master 70ead82 184/215: Correct "breakpoint deleted" regexp, Rocky Bernstein, 2016/07/30
- [elpa] master b71750a 193/215: Relax deleted breakpoint regexp in PDB to support Python 2 and 3, Rocky Bernstein, 2016/07/30
- [elpa] master 2f30f42 176/215: Merge pull request #119 from realgud/improve-break-C-u, Rocky Bernstein, 2016/07/30
- [elpa] master cbfa182 203/215: Improve realgud:run-process docstring, Rocky Bernstein, 2016/07/30
- [elpa] master 333a946 104/215: Merge pull request #74 from rocky/ipdb, Rocky Bernstein, 2016/07/30