diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2019-10-20 13:10:59 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-10-20 13:11:04 +0200 |
commit | a4e7c15484a9330fb9e1a1b425fcf1b37bad04e1 (patch) | |
tree | 33db809baf378a77d04002d338c291232e12acb7 /lisp/emacs-lisp | |
parent | 0cbcd2869e46f2ede0d08fd183d6c0ad0ebd8394 (diff) | |
download | emacs-a4e7c15484a9330fb9e1a1b425fcf1b37bad04e1.tar.gz emacs-a4e7c15484a9330fb9e1a1b425fcf1b37bad04e1.tar.bz2 emacs-a4e7c15484a9330fb9e1a1b425fcf1b37bad04e1.zip |
Preserve breakpoints when Edebug-reinstrumenting functions
* lisp/emacs-lisp/edebug.el (edebug--overlay-breakpoints): New
function (bug#23470).
* lisp/emacs-lisp/seq.el (seq-position): Autoload.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/edebug.el | 33 | ||||
-rw-r--r-- | lisp/emacs-lisp/seq.el | 1 |
2 files changed, 28 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 893c821f086..68b2126345f 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -1403,15 +1403,33 @@ contains a circular object." (put edebug-def-name 'edebug ;; A struct or vector would be better here!! (list edebug-form-begin-marker - nil ; clear breakpoints + (edebug--restore-breakpoints edebug-old-def-name) edebug-offset-list - edebug-top-window-data - )) + edebug-top-window-data)) (funcall edebug-new-definition-function edebug-def-name) result ))) +(defun edebug--restore-breakpoints (name) + (let* ((data (get name 'edebug)) + (offsets (nth 2 data)) + (breakpoints (nth 1 data)) + (start (nth 0 data)) + index) + ;; Breakpoints refer to offsets from the start of the function. + ;; The start position is a marker, so it'll move around in a + ;; similar fashion as the breakpoint markers. If we find a + ;; breakpoint marker that refers to an offset (which is a place + ;; where breakpoints can be made), then we restore it. + (cl-loop for breakpoint in breakpoints + for marker = (nth 3 breakpoint) + when (and (marker-position marker) + (setq index (seq-position + offsets + (- (marker-position marker) start)))) + collect (cons index (cdr breakpoint))))) + (defun edebug-new-definition (def-name) "Set up DEF-NAME to use Edebug's instrumentation functions." (put def-name 'edebug-behavior 'edebug) @@ -3166,6 +3184,7 @@ the breakpoint." (edebug-def-mark (car edebug-data)) (edebug-breakpoints (car (cdr edebug-data))) (offset-vector (nth 2 edebug-data)) + (position (+ edebug-def-mark (aref offset-vector index))) present) ;; delete it either way (setq present (assq index edebug-breakpoints)) @@ -3176,8 +3195,10 @@ the breakpoint." (setq edebug-breakpoints (edebug-sort-alist (cons - (list index condition temporary) - edebug-breakpoints) '<)) + (list index condition temporary + (set-marker (make-marker) position)) + edebug-breakpoints) + '<)) (if condition (message "Breakpoint set in %s with condition: %s" edebug-def-name condition) @@ -3187,7 +3208,7 @@ the breakpoint." (message "No breakpoint here"))) (setcar (cdr edebug-data) edebug-breakpoints) - (goto-char (+ edebug-def-mark (aref offset-vector index))) + (goto-char position) (edebug--overlay-breakpoints edebug-def-name))))) (defun edebug--overlay-breakpoints (function) diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index f001dceecec..8d4093004a7 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -380,6 +380,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." (and (seq-every-p (lambda (item1) (seq-contains-p sequence2 item1 testfn)) sequence1) (seq-every-p (lambda (item2) (seq-contains-p sequence1 item2 testfn)) sequence2))) +;;;###autoload (cl-defgeneric seq-position (sequence elt &optional testfn) "Return the index of the first element in SEQUENCE that is equal to ELT. Equality is defined by TESTFN if non-nil or by `equal' if nil." |