aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGemini Lasswell2019-07-30 10:00:27 -0700
committerGemini Lasswell2019-09-13 13:43:07 -0700
commit2093395dbf8563af38f206950d95f0bc20183b9c (patch)
tree0e4c7788113b296bf768c125925e3061546e898a /lisp
parent224534ab8d3f60fea28b271859f8eaf373f95089 (diff)
downloademacs-2093395dbf8563af38f206950d95f0bc20183b9c.tar.gz
emacs-2093395dbf8563af38f206950d95f0bc20183b9c.zip
Improve print output options commands in backtrace-mode (bug#36566)
* lisp/emacs-lisp/backtrace.el (backtrace-view): Mention :print-gensym in docstring. (backtrace-mode-map): Add keyboard binding for backtrace-toggle-print-gensym. Add menu entries for backtrace-toggle-print-circle and backtrace-toggle-print-gensym. (backtrace--with-output-variables): Bind print-gensym with value of :print-gensym found in view plist. (backtrace-toggle-print-circle): Remove description of implementation details from docstring. (backtrace-toggle-print-gensym): New command. (backtrace--toggle-feature): Add echo area message describing result of command. * test/lisp/emacs-lisp/backtrace-tests.el (backtrace-tests--print-circle): New test. * doc/lispref/debugging.texi (Backtraces): Document keyboard binding for backtrace-toggle-print-gensym.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/backtrace.el44
1 files changed, 34 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index 60d146e24a8..0c4c7987c3c 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -175,7 +175,8 @@ This should be a list of `backtrace-frame' objects.")
175 175
176(defvar-local backtrace-view nil 176(defvar-local backtrace-view nil
177 "A plist describing how to render backtrace frames. 177 "A plist describing how to render backtrace frames.
178Possible entries are :show-flags, :show-locals and :print-circle.") 178Possible entries are :show-flags, :show-locals, :print-circle
179and :print-gensym.")
179 180
180(defvar-local backtrace-insert-header-function nil 181(defvar-local backtrace-insert-header-function nil
181 "Function for inserting a header for the current Backtrace buffer. 182 "Function for inserting a header for the current Backtrace buffer.
@@ -205,6 +206,7 @@ frames where the source code location is known.")
205 (define-key map "p" 'backtrace-backward-frame) 206 (define-key map "p" 'backtrace-backward-frame)
206 (define-key map "v" 'backtrace-toggle-locals) 207 (define-key map "v" 'backtrace-toggle-locals)
207 (define-key map "#" 'backtrace-toggle-print-circle) 208 (define-key map "#" 'backtrace-toggle-print-circle)
209 (define-key map ":" 'backtrace-toggle-print-gensym)
208 (define-key map "s" 'backtrace-goto-source) 210 (define-key map "s" 'backtrace-goto-source)
209 (define-key map "\C-m" 'backtrace-help-follow-symbol) 211 (define-key map "\C-m" 'backtrace-help-follow-symbol)
210 (define-key map "+" 'backtrace-multi-line) 212 (define-key map "+" 'backtrace-multi-line)
@@ -224,6 +226,18 @@ frames where the source code location is known.")
224 :active (backtrace-get-index) 226 :active (backtrace-get-index)
225 :selected (plist-get (backtrace-get-view) :show-locals) 227 :selected (plist-get (backtrace-get-view) :show-locals)
226 :help "Show or hide the local variables for the frame at point"] 228 :help "Show or hide the local variables for the frame at point"]
229 ["Show Circular Structures" backtrace-toggle-print-circle
230 :style toggle
231 :active (backtrace-get-index)
232 :selected (plist-get (backtrace-get-view) :print-circle)
233 :help
234 "Condense or expand shared or circular structures in the frame at point"]
235 ["Show Uninterned Symbols" backtrace-toggle-print-gensym
236 :style toggle
237 :active (backtrace-get-index)
238 :selected (plist-get (backtrace-get-view) :print-gensym)
239 :help
240 "Toggle unique printing of uninterned symbols in the frame at point"]
227 ["Expand \"...\"s" backtrace-expand-ellipses 241 ["Expand \"...\"s" backtrace-expand-ellipses
228 :help "Expand all the abbreviated forms in the current frame"] 242 :help "Expand all the abbreviated forms in the current frame"]
229 ["Show on Multiple Lines" backtrace-multi-line 243 ["Show on Multiple Lines" backtrace-multi-line
@@ -339,6 +353,7 @@ It runs `backtrace-revert-hook', then calls `backtrace-print'."
339 `(let ((print-escape-control-characters t) 353 `(let ((print-escape-control-characters t)
340 (print-escape-newlines t) 354 (print-escape-newlines t)
341 (print-circle (plist-get ,view :print-circle)) 355 (print-circle (plist-get ,view :print-circle))
356 (print-gensym (plist-get ,view :print-gensym))
342 (standard-output (current-buffer))) 357 (standard-output (current-buffer)))
343 ,@body)) 358 ,@body))
344 359
@@ -420,12 +435,18 @@ Set it to VALUE unless the button is a `backtrace-ellipsis' button."
420 435
421(defun backtrace-toggle-print-circle (&optional all) 436(defun backtrace-toggle-print-circle (&optional all)
422 "Toggle `print-circle' for the backtrace frame at point. 437 "Toggle `print-circle' for the backtrace frame at point.
423With prefix argument ALL, toggle the value of :print-circle in 438With prefix argument ALL, toggle the default value bound to
424`backtrace-view', which affects all of the backtrace frames in 439`print-circle' for all the frames in the buffer."
425the buffer."
426 (interactive "P") 440 (interactive "P")
427 (backtrace--toggle-feature :print-circle all)) 441 (backtrace--toggle-feature :print-circle all))
428 442
443(defun backtrace-toggle-print-gensym (&optional all)
444 "Toggle `print-gensym' for the backtrace frame at point.
445With prefix argument ALL, toggle the default value bound to
446`print-gensym' for all the frames in the buffer."
447 (interactive "P")
448 (backtrace--toggle-feature :print-gensym all))
449
429(defun backtrace--toggle-feature (feature all) 450(defun backtrace--toggle-feature (feature all)
430 "Toggle FEATURE for the current backtrace frame or for the buffer. 451 "Toggle FEATURE for the current backtrace frame or for the buffer.
431FEATURE should be one of the options in `backtrace-view'. If ALL 452FEATURE should be one of the options in `backtrace-view'. If ALL
@@ -450,12 +471,15 @@ position point at the start of the frame it was in before."
450 (goto-char (point-min)) 471 (goto-char (point-min))
451 (while (and (not (eql index (backtrace-get-index))) 472 (while (and (not (eql index (backtrace-get-index)))
452 (< (point) (point-max))) 473 (< (point) (point-max)))
453 (goto-char (backtrace-get-frame-end))))) 474 (goto-char (backtrace-get-frame-end))))
454 (let ((index (backtrace-get-index))) 475 (message "%s is now %s for all frames"
455 (unless index 476 (substring (symbol-name feature) 1) value))
456 (user-error "Not in a stack frame")) 477 (unless (backtrace-get-index)
457 (backtrace--set-feature feature 478 (user-error "Not in a stack frame"))
458 (not (plist-get (backtrace-get-view) feature)))))) 479 (let ((value (not (plist-get (backtrace-get-view) feature))))
480 (backtrace--set-feature feature value)
481 (message "%s is now %s for this frame"
482 (substring (symbol-name feature) 1) value))))
459 483
460(defun backtrace--set-feature (feature value) 484(defun backtrace--set-feature (feature value)
461 "Set FEATURE in the view plist of the frame at point to VALUE. 485 "Set FEATURE in the view plist of the frame at point to VALUE.