[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/backtrace-mode db5f876 08/11: Add link in backtrac
From: |
Gemini Lasswell |
Subject: |
[Emacs-diffs] scratch/backtrace-mode db5f876 08/11: Add link in backtraces to position in buffer being evaluated (bug#14081) |
Date: |
Sun, 15 Jul 2018 15:06:19 -0400 (EDT) |
branch: scratch/backtrace-mode
commit db5f876ac1f63d559cf313b405497358f83e6805
Author: Gemini Lasswell <address@hidden>
Commit: Gemini Lasswell <address@hidden>
Add link in backtraces to position in buffer being evaluated (bug#14081)
* lisp/emacs-lisp/backtrace.el (backtrace-frame): Add buffer field.
(backtrace-get-frames): Set buffer field of frame.
(backtrace-buffer-pos): New button type.
(backtrace--pop-to-buffer-pos): New function.
(backtrace--print-func-and-args): Create a button for the buffer
position if it is set.
---
lisp/emacs-lisp/backtrace.el | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index f47c7c5..9eb8197 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -65,7 +65,7 @@ guaranteed."
(cl-defstruct
(backtrace-frame
(:constructor backtrace-make-frame))
- evald fun args flags locals pos)
+ evald fun args flags locals buffer pos)
(cl-defun backtrace-get-frames
(&optional base &key (constructor #'backtrace-make-frame))
@@ -98,9 +98,26 @@ frames before its nearest activation frame are discarded."
;; eval-region calls for the same buffer. That's not a very
;; useful case.
(with-current-buffer (pop eval-buffers)
+ (setf (backtrace-frame-buffer frame) (current-buffer))
(setf (backtrace-frame-pos frame) (point))))))
frames))
+;; Button definition for jumping to a buffer position.
+
+(define-button-type 'backtrace-buffer-pos
+ 'action #'backtrace--pop-to-buffer-pos
+ 'help-echo "mouse-2, RET: Show reading position")
+
+(defun backtrace--pop-to-buffer-pos (button)
+ "Pop to the buffer and position for the BUTTON at point."
+ (let* ((buffer (button-get button 'backtrace-buffer))
+ (pos (button-get button 'backtrace-pos)))
+ (if (buffer-live-p buffer)
+ (progn
+ (pop-to-buffer buffer)
+ (goto-char (max (point-min) (min (point-max) pos))))
+ (message "Buffer has been killed"))))
+
;; Font Locking support
(defconst backtrace--font-lock-keywords
@@ -726,8 +743,12 @@ Format it according to VIEW."
;; After any frame that uses eval-buffer, insert a comment that
;; states the buffer position it's reading at.
(when (backtrace-frame-pos frame)
- (insert (format " ; Reading at buffer position %d"
- (backtrace-frame-pos frame))))
+ (insert " ; Reading at ")
+ (let ((pos (point)))
+ (insert (format "buffer position %d" (backtrace-frame-pos frame)))
+ (make-button pos (point) :type 'backtrace-buffer-pos
+ 'backtrace-buffer (backtrace-frame-buffer frame)
+ 'backtrace-pos (backtrace-frame-pos frame))))
(insert "\n")
(put-text-property beg (point) 'backtrace-section 'func)))
- [Emacs-diffs] branch scratch/backtrace-mode created (now fb3578b), Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode db5f876 08/11: Add link in backtraces to position in buffer being evaluated (bug#14081),
Gemini Lasswell <=
- [Emacs-diffs] scratch/backtrace-mode 2ed27cf 07/11: Add links in backtraces to functions written in C (bug#25393), Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 86f69ed 04/11: Initialize backtrace display options in backtrace-mode, Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 2e73307 10/11: Change keybinding for backtrace-collapse from '=' to '-', Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 923d3a6 06/11: Add prefix argument to backtrace-toggle-print-circle, Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 2276cc2 05/11: Lazily print backtrace frame local variables, Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 3c4f9e9 02/11: Add methods for strings to cl-print, Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 8d270bd 01/11: Support ellipsis expansion in cl-print, Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode fb3578b 11/11: Add new command to expand all "..."s in a backtrace frame, Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 425cb61 09/11: Add more tests for backtrace-mode, Gemini Lasswell, 2018/07/15
- [Emacs-diffs] scratch/backtrace-mode 6c62b9e 03/11: Add backtrace-mode and use it in the debugger, ERT and Edebug, Gemini Lasswell, 2018/07/15