aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2011-09-13 17:02:27 -0400
committerGlenn Morris2011-09-13 17:02:27 -0400
commit8e39b2e837bb3de939eda51074b6c6f95aaef5f2 (patch)
tree4cfc68282c9fa034232a838ff4c0e09931dfd011
parent85e9c04bf3633646b6d41ef0474805af6383a508 (diff)
downloademacs-8e39b2e837bb3de939eda51074b6c6f95aaef5f2.tar.gz
emacs-8e39b2e837bb3de939eda51074b6c6f95aaef5f2.zip
* lisp/emacs-lisp/debug.el (debugger-make-xrefs): Preserve point. (Bug#9462)
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/emacs-lisp/debug.el131
2 files changed, 71 insertions, 65 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 73384823c48..a689b696f2f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12011-09-13 Glenn Morris <rgm@gnu.org>
2
3 * emacs-lisp/debug.el (debugger-make-xrefs):
4 Preserve point. (Bug#9462)
5
12011-09-13 Chong Yidong <cyd@stupidchicken.com> 62011-09-13 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * window.el (window-deletable-p): Use next-frame. 8 * window.el (window-deletable-p): Use next-frame.
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 8276030ccf8..6533721054c 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -342,71 +342,72 @@ That buffer should be current already."
342 "Attach cross-references to function names in the `*Backtrace*' buffer." 342 "Attach cross-references to function names in the `*Backtrace*' buffer."
343 (interactive "b") 343 (interactive "b")
344 (with-current-buffer (or buffer (current-buffer)) 344 (with-current-buffer (or buffer (current-buffer))
345 (setq buffer (current-buffer)) 345 (save-excursion
346 (let ((inhibit-read-only t) 346 (setq buffer (current-buffer))
347 (old-end (point-min)) (new-end (point-min))) 347 (let ((inhibit-read-only t)
348 ;; If we saved an old backtrace, find the common part 348 (old-end (point-min)) (new-end (point-min)))
349 ;; between the new and the old. 349 ;; If we saved an old backtrace, find the common part
350 ;; Compare line by line, starting from the end, 350 ;; between the new and the old.
351 ;; because that's the part that is likely to be unchanged. 351 ;; Compare line by line, starting from the end,
352 (if debugger-previous-backtrace 352 ;; because that's the part that is likely to be unchanged.
353 (let (old-start new-start (all-match t)) 353 (if debugger-previous-backtrace
354 (goto-char (point-max)) 354 (let (old-start new-start (all-match t))
355 (with-temp-buffer 355 (goto-char (point-max))
356 (insert debugger-previous-backtrace) 356 (with-temp-buffer
357 (while (and all-match (not (bobp))) 357 (insert debugger-previous-backtrace)
358 (setq old-end (point)) 358 (while (and all-match (not (bobp)))
359 (forward-line -1) 359 (setq old-end (point))
360 (setq old-start (point)) 360 (forward-line -1)
361 (with-current-buffer buffer 361 (setq old-start (point))
362 (setq new-end (point)) 362 (with-current-buffer buffer
363 (forward-line -1) 363 (setq new-end (point))
364 (setq new-start (point))) 364 (forward-line -1)
365 (if (not (zerop 365 (setq new-start (point)))
366 (let ((case-fold-search nil)) 366 (if (not (zerop
367 (compare-buffer-substrings 367 (let ((case-fold-search nil))
368 (current-buffer) old-start old-end 368 (compare-buffer-substrings
369 buffer new-start new-end)))) 369 (current-buffer) old-start old-end
370 (setq all-match nil)))) 370 buffer new-start new-end))))
371 ;; Now new-end is the position of the start of the 371 (setq all-match nil))))
372 ;; unchanged part in the current buffer, and old-end is 372 ;; Now new-end is the position of the start of the
373 ;; the position of that same text in the saved old 373 ;; unchanged part in the current buffer, and old-end is
374 ;; backtrace. But we must subtract (point-min) since strings are 374 ;; the position of that same text in the saved old
375 ;; indexed in origin 0. 375 ;; backtrace. But we must subtract (point-min) since strings are
376 376 ;; indexed in origin 0.
377 ;; Replace the unchanged part of the backtrace 377
378 ;; with the text from debugger-previous-backtrace, 378 ;; Replace the unchanged part of the backtrace
379 ;; since that already has the proper xrefs. 379 ;; with the text from debugger-previous-backtrace,
380 ;; With this optimization, we only need to scan 380 ;; since that already has the proper xrefs.
381 ;; the changed part of the backtrace. 381 ;; With this optimization, we only need to scan
382 (delete-region new-end (point-max)) 382 ;; the changed part of the backtrace.
383 (goto-char (point-max)) 383 (delete-region new-end (point-max))
384 (insert (substring debugger-previous-backtrace 384 (goto-char (point-max))
385 (- old-end (point-min)))) 385 (insert (substring debugger-previous-backtrace
386 ;; Make the unchanged part of the backtrace inaccessible 386 (- old-end (point-min))))
387 ;; so it won't be scanned. 387 ;; Make the unchanged part of the backtrace inaccessible
388 (narrow-to-region (point-min) new-end))) 388 ;; so it won't be scanned.
389 389 (narrow-to-region (point-min) new-end)))
390 ;; Scan the new part of the backtrace, inserting xrefs. 390
391 (goto-char (point-min)) 391 ;; Scan the new part of the backtrace, inserting xrefs.
392 (while (progn 392 (goto-char (point-min))
393 (goto-char (+ (point) 2)) 393 (while (progn
394 (skip-syntax-forward "^w_") 394 (goto-char (+ (point) 2))
395 (not (eobp))) 395 (skip-syntax-forward "^w_")
396 (let* ((beg (point)) 396 (not (eobp)))
397 (end (progn (skip-syntax-forward "w_") (point))) 397 (let* ((beg (point))
398 (sym (intern-soft (buffer-substring-no-properties 398 (end (progn (skip-syntax-forward "w_") (point)))
399 beg end))) 399 (sym (intern-soft (buffer-substring-no-properties
400 (file (and sym (symbol-file sym 'defun)))) 400 beg end)))
401 (when file 401 (file (and sym (symbol-file sym 'defun))))
402 (goto-char beg) 402 (when file
403 ;; help-xref-button needs to operate on something matched 403 (goto-char beg)
404 ;; by a regexp, so set that up for it. 404 ;; help-xref-button needs to operate on something matched
405 (re-search-forward "\\(\\sw\\|\\s_\\)+") 405 ;; by a regexp, so set that up for it.
406 (help-xref-button 0 'help-function-def sym file))) 406 (re-search-forward "\\(\\sw\\|\\s_\\)+")
407 (forward-line 1)) 407 (help-xref-button 0 'help-function-def sym file)))
408 (widen)) 408 (forward-line 1))
409 (setq debugger-previous-backtrace (buffer-string)))) 409 (widen))
410 (setq debugger-previous-backtrace (buffer-string)))))
410 411
411(defun debugger-step-through () 412(defun debugger-step-through ()
412 "Proceed, stepping through subexpressions of this expression. 413 "Proceed, stepping through subexpressions of this expression.