[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b275bd2 119/215: Improve behavior of delete, enable, and d
From: |
Rocky Bernstein |
Subject: |
[elpa] master b275bd2 119/215: Improve behavior of delete, enable, and disable |
Date: |
Sat, 30 Jul 2016 14:48:59 +0000 (UTC) |
branch: master
commit b275bd2455e07906284aba9ba2b77060037cd0e7
Author: Clément Pit--Claudel <address@hidden>
Commit: Clément Pit--Claudel <address@hidden>
Improve behavior of delete, enable, and disable
Interactively, these three commands now disable, enable, or delete a
breakpoint found on the current line, and only prompt for a breakpoint
number if they can't find one.
This default behavior is overridden in two cases:
* When a numeric prefix argument is given, in which case they use that
as the breakpoint number (consistent with current behavior)
* When a generic prefix argument is given, in which case they always
prompt, but offer a breakpoint number on the current line as the
default.
Closes #87.
---
realgud/common/cmds.el | 67 ++++++++++++++++++++++++++++++++----------------
1 file changed, 45 insertions(+), 22 deletions(-)
diff --git a/realgud/common/cmds.el b/realgud/common/cmds.el
index 21eaa57..014888a 100644
--- a/realgud/common/cmds.el
+++ b/realgud/common/cmds.el
@@ -93,28 +93,51 @@ a shortcut for that key."
(realgud:cmd-remap arg "continue" "continue" "c")
)
-(defun realgud:cmd-delete(&optional arg)
- "Delete breakpoint by number."
- (interactive "pBreakpoint number: ")
- (let* ((line-num (line-number-at-pos))
- (arg (realgud-get-bpnum-from-line-num line-num)))
- (if arg
- (realgud:cmd-remap arg "delete" "delete %p" "D")
- (message "Can't find breakpoint at line %d" line-num))
- )
- )
-
-(defun realgud:cmd-disable(&optional arg)
- "Disable breakpoint."
- (interactive "NBreakpoint number: ")
- (realgud:cmd-remap arg "disable" "disable %p" "-")
- )
-
-(defun realgud:cmd-enable(&optional arg)
- "Enable breakpoint."
- (interactive "NBreakpoint number: ")
- (realgud:cmd-remap arg "enable" "enable %p" "+")
- )
+(defun realgud:bpnum-on-current-line()
+ "Return number of one breakpoint on current line, if any.
+If none is found, return nil."
+ (realgud-get-bpnum-from-line-num (line-number-at-pos)))
+
+(defun realgud:bpnum-from-prefix-arg()
+ "Return number of one breakpoint on current line, if any.
+If none is found, or if `current-prefix-arg' is a cons (i.e. a
+C-u prefix arg), ask user for a breakpoint number. If
+`current-prefix-arg' is a number (i.e. a numeric prefix arg),
+return it unmodified."
+ (let ((must-prompt (consp current-prefix-arg))
+ (current-bp (realgud:bpnum-on-current-line)))
+ (list
+ (if (numberp current-prefix-arg)
+ current-prefix-arg
+ (or (and (not must-prompt) current-bp)
+ (read-number "Breakpoint number: " current-bp))))))
+
+(defun realgud:cmd-delete(bpnum)
+ "Delete breakpoint by number.
+Interactively, find breakpoint on current line, if any. With
+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-remap bpnum "delete" "delete %p" "D"))
+
+(defun realgud:cmd-disable(bpnum)
+ "Disable breakpoint BPNUM.
+Interactively, find breakpoint on current line, if any. With
+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-remap bpnum "disable" "disable %p" "-"))
+
+(defun realgud:cmd-enable(bpnum)
+ "Enable breakpoint BPNUM.
+Interactively, find breakpoint on current line, if any. With
+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-remap bpnum "enable" "enable %p" "+"))
(defun realgud:cmd-eval(arg)
"Evaluate an expression."
- [elpa] master 72c83d7 114/215: Improve command mappings in pdb-command-hash, (continued)
- [elpa] master 72c83d7 114/215: Improve command mappings in pdb-command-hash, Rocky Bernstein, 2016/07/30
- [elpa] master ff1dfe9 078/215: Change fringe arrow background colors based on dark or light background., Rocky Bernstein, 2016/07/30
- [elpa] master 45fb7cc 085/215: Add ability to have alternate group location file and line numbers., Rocky Bernstein, 2016/07/30
- [elpa] master baab01d 061/215: Merge branch 'master' of github.com:rocky/emacs-dbgr, Rocky Bernstein, 2016/07/30
- [elpa] master d437c3d 113/215: Merge pull request #81 from rocky/ipdb-complete, Rocky Bernstein, 2016/07/30
- [elpa] master 5155528 105/215: Bump version, Rocky Bernstein, 2016/07/30
- [elpa] master 76cb0d4 108/215: Fix wrong setq call, Rocky Bernstein, 2016/07/30
- [elpa] master 1716c8a 109/215: Towards fixing up tab completion in ipdb., Rocky Bernstein, 2016/07/30
- [elpa] master e04eeb2 117/215: Improve eval: run on region if active, and fall back to prompting, Rocky Bernstein, 2016/07/30
- [elpa] master fd00428 118/215: Merge pull request #86 from cpitclaudel/83-improve-e-binding, Rocky Bernstein, 2016/07/30
- [elpa] master b275bd2 119/215: Improve behavior of delete, enable, and disable,
Rocky Bernstein <=
- [elpa] master ca33520 120/215: Add a prefix arg to "continue" command, Rocky Bernstein, 2016/07/30
- [elpa] master 379528b 106/215: Disable ipdb until melpa is updated, Rocky Bernstein, 2016/07/30
- [elpa] master e049c12 124/215: Merge pull request #89 from cpitclaudel/87-improve-delete-command, Rocky Bernstein, 2016/07/30
- [elpa] master 91704f9 141/215: Automatically attach to a command buffer when enabling short-key-mode, Rocky Bernstein, 2016/07/30
- [elpa] master 40e73bc 123/215: Merge pull request #92 from cpitclaudel/82-add-safe-mode, Rocky Bernstein, 2016/07/30
- [elpa] master f3426ed 072/215: Merge branch 'master' of github.com:rocky/emacs-dbgr, Rocky Bernstein, 2016/07/30
- [elpa] master 4e85910 088/215: Add pytest error message pattern in python debuggers, Rocky Bernstein, 2016/07/30
- [elpa] master 01617c5 100/215: ipdb: add regex test, Rocky Bernstein, 2016/07/30
- [elpa] master 5395757 091/215: More cleanup from last two commits., Rocky Bernstein, 2016/07/30
- [elpa] master 1e2fe55 098/215: Add rspec loc pattern.., Rocky Bernstein, 2016/07/30