[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/realgud 7cc1230 047/140: extract method for breakpoint
From: |
Rocky Bernstein |
Subject: |
[elpa] externals/realgud 7cc1230 047/140: extract method for breakpoint stuff in realgud:track-from-region |
Date: |
Sat, 25 May 2019 19:35:30 -0400 (EDT) |
branch: externals/realgud
commit 7cc123013cdae5b8f46353ca990d03fc193c713a
Author: Jacob O'Donnell <address@hidden>
Commit: Jacob O'Donnell <address@hidden>
extract method for breakpoint stuff in realgud:track-from-region
---
realgud/common/track.el | 41 +++++++++++++++++++++++------------------
test/test-track.el | 23 +++++++++++++++++++++++
2 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/realgud/common/track.el b/realgud/common/track.el
index 1bae618..164edc4 100644
--- a/realgud/common/track.el
+++ b/realgud/common/track.el
@@ -223,18 +223,17 @@ evaluating (realgud-cmdbuf-info-loc-regexp
realgud-cmdbuf-info)"
;; in frame-num. Otherwise, nil.
(frame-num)
(text-sans-loc)
- (bp-loc)
(cmdbuf (or opt-cmdbuf (current-buffer)))
)
(unless (realgud:track-complain-if-not-in-cmd-buffer cmdbuf t)
(if (realgud:eval-command-p text)
(realgud:message-eval-results text))
- (if (not (equal "" text))
- (with-current-buffer cmdbuf
+ (if (not (equal "" text))
+ (with-current-buffer cmdbuf
(if (realgud-sget 'cmdbuf-info 'divert-output?)
(realgud-track-divert-prompt text cmdbuf to))
- ;; FIXME: instead of these fixed filters,
+ ;; FIXME: instead of these fixed filters,
;; put into a list and iterate over that.
(realgud-track-termination? text)
(setq text-sans-loc (or (realgud-track-loc-remaining text) text))
@@ -249,13 +248,8 @@ evaluating (realgud-cmdbuf-info-loc-regexp
realgud-cmdbuf-info)"
(setq loc (realgud-track-loc-from-selected-frame
text cmd-mark)))
- (setq bp-loc (realgud-track-bp-loc text-sans-loc cmd-mark cmdbuf))
- (if bp-loc
- (let ((src-buffer (realgud-loc-goto bp-loc)))
- (realgud-cmdbuf-add-srcbuf src-buffer cmdbuf)
- (with-current-buffer src-buffer
- (realgud-bp-add-info bp-loc)
- )))
+ (realgud:track-add-breakpoint (realgud-track-bp-loc
text-sans-loc cmd-mark cmdbuf) cmdbuf)
+
(if loc
(let ((selected-frame
(or (not frame-num)
@@ -264,18 +258,30 @@ evaluating (realgud-cmdbuf-info-loc-regexp
realgud-cmdbuf-info)"
shortkey-on-tracing?)
(realgud-cmdbuf-info-in-debugger?= 't)
(realgud-cmdbuf-mode-line-update))
- (dolist (bp-loc (realgud-track-bp-delete text-sans-loc
cmd-mark cmdbuf))
- (let ((src-buffer (realgud-loc-goto bp-loc)))
- (realgud-cmdbuf-add-srcbuf src-buffer cmdbuf)
- (with-current-buffer src-buffer
- (realgud-bp-del-info bp-loc)
- ))))
+ (realgud:track-remove-breakpoints
+ (realgud-track-bp-delete text-sans-loc cmd-mark cmdbuf)))
)
)
)
)
)
+(defun realgud:track-add-breakpoint (bp-loc cmdbuf)
+ "Add a breakpoint fringe in source window if BP-LOC."
+ (if bp-loc
+ (let ((src-buffer (realgud-loc-goto bp-loc)))
+ (realgud-cmdbuf-add-srcbuf src-buffer cmdbuf)
+ (with-current-buffer src-buffer
+ (realgud-bp-add-info bp-loc)))))
+
+(defun realgud:track-remove-breakpoints (bp-locs cmdbuf)
+ "Remove all breakpoints in source window found in BP-LOCS."
+ (dolist (bp-loc bp-locs)
+ (let ((src-buffer (realgud-loc-goto bp-loc)))
+ (realgud-cmdbuf-add-srcbuf src-buffer cmdbuf)
+ (with-current-buffer src-buffer
+ (realgud-bp-del-info bp-loc)))))
+
(defun realgud-track-hist-fn-internal(fn)
"Update both command buffer and a source buffer to reflect the
selected location in the location history. If we started in a
@@ -582,7 +588,6 @@ of the breakpoints found in command buffer."
; that struct is the regexp hash to match positions. By setting the
; the fields of realgud-cmdbuf-info appropriately we can accomodate a
; family of debuggers -- one at a time -- for the buffer process.
-
(setq cmdbuf (or cmdbuf (current-buffer)))
(with-current-buffer cmdbuf
(unless (realgud:track-complain-if-not-in-cmd-buffer cmdbuf t)
diff --git a/test/test-track.el b/test/test-track.el
index cbc4da0..6e99c05 100644
--- a/test/test-track.el
+++ b/test/test-track.el
@@ -26,6 +26,8 @@
(declare-function realgud:eval-command-p 'realgud-track)
(declare-function realgud-set-command-name-hash-to-buffer-local 'realgud-track)
(declare-function realgud:truncate-eval-message 'realgud-track)
+(declare-function realgud:track-add-breakpoint 'realgud-track)
+(declare-function realgud:track-remove-breakpoints 'realgud-track)
(test-simple-start)
@@ -127,6 +129,27 @@ trepan: That's all, folks...
(assert-equal (realgud:truncate-eval-message "cat") "cat"))
+(note "realgud:track-remove-breakpoints")
+(with-temp-file "test_file.py"
+ (insert "if 1:\n x = x + 1\n"))
+
+(setq test-buffer (find-file "test_file.py"))
+(realgud-cmdbuf-init test-buffer "trepan"
+ (gethash "trepan" realgud-pat-hash))
+
+(setq bp-num 1)
+(setq debugger-bp-output (format "Breakpoint %d set at line %d\n\tin
file %s."
+ bp-num 1 buffer-file-name))
+(save-excursion
+ (setq bp-loc (realgud-track-bp-loc debugger-bp-output nil))
+ (let ((num-overlays (length (overlays-in 0 (point-max)))))
+ (realgud:track-add-breakpoint bp-loc test-buffer)
+ (assert-equal (+ 1 num-overlays) (length (overlays-in 0 (point-max))))
+ (realgud:track-remove-breakpoints (list bp-loc) (current-buffer))
+ (assert-equal num-overlays (length (overlays-in 0 (point-max))))))
+(kill-buffer "test_file.py")
+(delete-file "test_file.py")
+
;; (setq debugger-bp-output (format "Breakpoint %d set at line %d\n\tin file
%s.\n"
;; bp-num line-number test-filename))
;; (setq bp-loc (realgud-track-bp-loc debugger-bp-output nil))
- [elpa] externals/realgud 4a7f6ef 019/140: Fix infinite loop in realgud:backtrace-init, (continued)
- [elpa] externals/realgud 4a7f6ef 019/140: Fix infinite loop in realgud:backtrace-init, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 081f7ed 018/140: Expand script path where appropriate, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 1180d9f 028/140: add eval at point and bind it to E in shortkey mode, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud f20f1e3 043/140: change E to put the thing at point in the eval buffer, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud e47abfb 044/140: Merge pull request #197 from jodonnell/eval-command, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud ce45b16 025/140: making join string not emacs 25 only, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud dc0e131 031/140: Guard against nil (realgud:get-command-name "eval"), Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud c64a4fd 039/140: Merge branch 'print', Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 2327213 026/140: adding tests for print to message area, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 7242eea 048/140: whitespace, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 7cc1230 047/140: extract method for breakpoint stuff in realgud:track-from-region,
Rocky Bernstein <=
- [elpa] externals/realgud aa933eb 038/140: Merge pull request #194 from jodonnell/print, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 2fad0c4 020/140: Add test case for an error when realgud:backtrace-init is hanging at startup, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 59b2563 023/140: Add gdb "delete" template, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud d9a3a92 046/140: Administrivia, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud bfabb0e 034/140: I am really bad with Elisp syntax, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 4692821 051/140: fixed an error, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 57eed60 027/140: making eval output truncate and saving all the current command hash, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 6986293 035/140: I am also bad at match relations, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud d00539e 030/140: Merge branch 'print' of https://github.com/jodonnell/realgud into print, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 90fe351 033/140: More Emacs-gaurded handling of realgud:join-string, Rocky Bernstein, 2019/05/25