[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master daac75b 175/215: Add a C-u interface to break and clear
From: |
Rocky Bernstein |
Subject: |
[elpa] master daac75b 175/215: Add a C-u interface to break and clear |
Date: |
Sat, 30 Jul 2016 14:49:04 +0000 (UTC) |
branch: master
commit daac75bb3187cdf1fe0c2e3a3ca73bfe40a3118a
Author: Clément Pit--Claudel <address@hidden>
Commit: Clément Pit--Claudel <address@hidden>
Add a C-u interface to break and clear
Prefix either command with C-u now prompts for a line number in the
current file, which prefixing with a numeric argument acts on that line.
---
realgud/common/cmds.el | 60 +++++++++++++++++++++++++++++++++++++++---------
realgud/common/send.el | 8 +++++++
2 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/realgud/common/cmds.el b/realgud/common/cmds.el
index 30b76cd..22a10f9 100644
--- a/realgud/common/cmds.el
+++ b/realgud/common/cmds.el
@@ -51,6 +51,39 @@ when command was run from a menu."
t)
t))
+(defun realgud:cmd--line-number-from-prefix-arg ()
+ "Guess or read a line number based on prefix arg.
+Returns (nil) for current line, and a list whose car is the line
+number otherwise."
+ (cond
+ ((numberp current-prefix-arg)
+ current-prefix-arg)
+ ((consp current-prefix-arg)
+ (let* ((min-line (save-excursion
+ (goto-char (point-min))
+ (line-number-at-pos)))
+ (max-line (save-excursion
+ (goto-char (point-max))
+ (line-number-at-pos)))
+ (prompt (format "Line number (%d..%d)? " min-line max-line))
+ (picked-line 0))
+ (while (not (<= min-line picked-line max-line))
+ (setq picked-line (read-number prompt)))
+ (list picked-line)))))
+
+(defmacro realgud:cmd--with-line-override (line &rest body)
+ "Run BODY with %l format specifier bound to LINE.
+This is needed because going to LINE explicitly would interfere
+with other motion initiated by debugger messages."
+ (declare (indent 1)
+ (debug t))
+ (let ((line-var (make-symbol "--line--")))
+ `(let* ((,line-var ,line)
+ (realgud-expand-format-overrides
+ (cons (cons ?l (and ,line-var (number-to-string ,line-var)))
+ realgud-expand-format-overrides)))
+ ,@body)))
+
(defconst realgud-cmd:default-hash
(let ((hash (make-hash-table :test 'equal)))
(puthash "backtrace" "backtrace" hash)
@@ -122,8 +155,8 @@ ARG, CMD-NAME, DEFAULT-CMD-TEMPLATE are as in
`realgud:cmd-run-command'.
KEY is ignored. NO-RECORD?, FRAME-SWITCH?, REALGUD-PROMPTS? are
as in `realgud:cmd-run-command'."
(realgud:cmd-run-command arg cmd-name default-cmd-template
- no-record? frame-switch?
- realgud-prompts?))
+ no-record? frame-switch?
+ realgud-prompts?))
(make-obsolete 'realgud:cmd-remap 'realgud:cmd-run-command "1.3.1")
@@ -133,15 +166,20 @@ as in `realgud:cmd-run-command'."
(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"))
+(defun realgud:cmd-break (&optional line-number)
+ "Set a breakpoint at the current line.
+With prefix argument LINE-NUMBER, prompt for line number."
+ (interactive (realgud:cmd--line-number-from-prefix-arg))
+ (realgud:cmd--with-line-override line-number
+ (realgud:cmd-run-command line-number
"break")))
+
+(defun realgud:cmd-clear(&optional line-number)
+ "Delete breakpoint at the current line.
+With prefix argument LINE-NUMBER, prompt for line number."
+ (interactive (realgud:cmd--line-number-from-prefix-arg))
+ (realgud:cmd--with-line-override line-number
+ (realgud:cmd-run-command line-number
"clear")))
-(defun realgud:cmd-clear(line-num)
- "Delete breakpoint at the current line"
- (interactive "p")
- (realgud:cmd-run-command line-num "clear"))
(defun realgud:cmd-continue(&optional arg)
"Continue execution.
@@ -207,7 +245,7 @@ be found on the current line, prompt for a breakpoint
number."
(let ((existing-bp-num (realgud:bpnum-on-current-line)))
(if existing-bp-num
(realgud:cmd-delete existing-bp-num)
- (realgud:cmd-break pos)))))
+ (realgud:cmd-break)))))
(defun realgud-cmds--mouse-add-remove-bp (event)
"Add or delete breakpoint on line pointed to by EVENT.
diff --git a/realgud/common/send.el b/realgud/common/send.el
index 648632b..c068c4f 100644
--- a/realgud/common/send.el
+++ b/realgud/common/send.el
@@ -116,6 +116,13 @@ results into the command buffer."
(defun realgud-send-command-invisible (command-str)
(realgud-send-command command-str (function realgud-send-command-process)))
+(defvar realgud-expand-format-overrides nil
+ "An alist of overrides for `realgud-expand-format'.
+Each element should have the form (KEY . VALUE). Key should be a
+single-character escape accepted by `realgud-expand-format';
+value should be a string. Every time %KEY is encountered in te
+string, it will be replaced by VALUE instead of being processed
+as usual. If VALUE is nil, the override is ignored.")
(defun realgud-expand-format (fmt-str &optional opt-str opt-buffer)
"Expands commands format characters inside FMT-STR.
@@ -148,6 +155,7 @@ taken from current buffer, or OPT-BUFFER if non-nil. Some
(concat
result (match-string 1 fmt-str)
(cond
+ ((cdr (assq key realgud-expand-format-overrides)))
((eq key ?d)
(or (and src-file-name
(file-name-directory src-file-name))
- [elpa] master 95f076e 150/215: Improve IPDB completion, (continued)
- [elpa] master 95f076e 150/215: Improve IPDB completion, Rocky Bernstein, 2016/07/30
- [elpa] master d45788c 152/215: Merge pull request #106 from rocky/75-ipdb-completion, Rocky Bernstein, 2016/07/30
- [elpa] master 032ea4b 143/215: Merge branch 'master' of github.com:rocky/emacs-dbgr, Rocky Bernstein, 2016/07/30
- [elpa] master 549f6f0 135/215: Merge pull request #98 from rocky/83-better-scope-keybindings, Rocky Bernstein, 2016/07/30
- [elpa] master aedea61 138/215: Merge pull request #101 from rocky/bp-icon-in-fringe, Rocky Bernstein, 2016/07/30
- [elpa] master 87d1ada 137/215: Refactor and improve breakpoint UI, Rocky Bernstein, 2016/07/30
- [elpa] master d6b879d 042/215: Merge branch 'trepanjs', Rocky Bernstein, 2016/07/30
- [elpa] master f3420e9 151/215: Merge pull request #105 from rocky/new-README, Rocky Bernstein, 2016/07/30
- [elpa] master 1c3d8c2 171/215: Add a bit of padding around the logo to make GitHub happy, Rocky Bernstein, 2016/07/30
- [elpa] master 678ec6b 139/215: Use `buffer-live-p' instead of `buffer-name' in `buffer-killed?', Rocky Bernstein, 2016/07/30
- [elpa] master daac75b 175/215: Add a C-u interface to break and clear,
Rocky Bernstein <=
- [elpa] master fe679e9 077/215: Don't try source buffer initialization if it doesn't exist., Rocky Bernstein, 2016/07/30
- [elpa] master 3f08b2b 165/215: Update screenshot, Rocky Bernstein, 2016/07/30
- [elpa] master 4ac3ca2 147/215: Fill in missing bits of Cask file, Rocky Bernstein, 2016/07/30
- [elpa] master 785eb68 168/215: Remove unwanted argument in call to cmd-run-command, Rocky Bernstein, 2016/07/30
- [elpa] master bc3fa20 162/215: Add some enable/disble patterns, Rocky Bernstein, 2016/07/30
- [elpa] master 2ca160c 080/215: Merge pull request #63 from cohomology/feature/empty_command_line, Rocky Bernstein, 2016/07/30
- [elpa] master 4f5c91f 177/215: Add basic support for jumping, Rocky Bernstein, 2016/07/30
- [elpa] master b7a7fe9 213/215: Release 1.4.0 which will be on melpa stable and elpa, Rocky Bernstein, 2016/07/30
- [elpa] master 260bc5a 187/215: Mark debuggers that don't have "jump"., Rocky Bernstein, 2016/07/30
- [elpa] master 3cb53e0 210/215: Assign more copyrights to FSF, Rocky Bernstein, 2016/07/30