[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/backtrace-mode 80d1c52 06/16: Add prefix argument
From: |
Gemini Lasswell |
Subject: |
[Emacs-diffs] scratch/backtrace-mode 80d1c52 06/16: Add prefix argument to backtrace-toggle-print-circle |
Date: |
Fri, 27 Jul 2018 15:25:58 -0400 (EDT) |
branch: scratch/backtrace-mode
commit 80d1c5220e48be3db42e2a0fe702ea428304f905
Author: Gemini Lasswell <address@hidden>
Commit: Gemini Lasswell <address@hidden>
Add prefix argument to backtrace-toggle-print-circle
With prefix argument, toggle print-circle for the whole buffer.
* lisp/emacs-lisp/backtrace.el (backtrace-toggle-print-circle): Add
universal prefix argument.
(backtrace--toggle-feature): Add new argument 'all' to toggle all
frames.
(backtrace--set-feature): New function.
(backtrace-mode): Use indent functions from Lisp modes.
---
lisp/emacs-lisp/backtrace.el | 89 ++++++++++++++++++++++++++++----------------
1 file changed, 56 insertions(+), 33 deletions(-)
diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index b896904..d6c04bb 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -349,39 +349,60 @@ Set it to VALUE unless the button is a
`backtrace-ellipsis' button."
(button-put beg 'skip value))
(setq beg (next-button beg)))))
-(defun backtrace-toggle-print-circle ()
- "Toggle `print-circle' for the backtrace frame at point."
- ;; TODO with argument, toggle the whole buffer.
- (interactive)
- (backtrace--toggle-feature :print-circle))
-
-(defun backtrace--toggle-feature (feature)
- "Toggle FEATURE for the backtrace frame at point.
-FEATURE should be one of the options in `backtrace-view'.
-After toggling the feature, reprint the frame and position
-point at the start of the section of the frame it was in
-before."
- (let ((index (backtrace-get-index))
- (view (copy-sequence (backtrace-get-view))))
- (unless index
- (user-error "Not in a stack frame"))
- (setq view (plist-put view feature (not (plist-get view feature))))
- (let ((inhibit-read-only t)
- (index (backtrace-get-index))
- (section (backtrace-get-section))
- (min (backtrace-get-frame-start))
- (max (backtrace-get-frame-end)))
- (delete-region min max)
- (goto-char min)
- (backtrace-print-frame (nth index backtrace-frames) view)
- (add-text-properties min (point)
- `(backtrace-index ,index backtrace-view ,view))
- (goto-char min)
- (when (not (eq section (backtrace-get-section)))
- (if-let ((pos (text-property-any (backtrace-get-frame-start)
- (backtrace-get-frame-end)
- 'backtrace-section section)))
- (goto-char pos))))))
+(defun backtrace-toggle-print-circle (&optional all)
+ "Toggle `print-circle' for the backtrace frame at point.
+With prefix argument ALL, toggle the value of :print-circle in
+`backtrace-view', which affects all of the backtrace frames in
+the buffer."
+ (interactive "P")
+ (backtrace--toggle-feature :print-circle all))
+
+(defun backtrace--toggle-feature (feature all)
+ "Toggle FEATURE for the current backtrace frame or for the buffer.
+FEATURE should be one of the options in `backtrace-view'. If ALL
+is non-nil, toggle FEATURE for all frames in the buffer. After
+toggling the feature, reprint the affected frame(s). Afterwards
+position point at the start of the frame it was in before."
+ (if all
+ (let ((index (backtrace-get-index))
+ (pos (point))
+ (at-end (= (point) (point-max)))
+ (value (not (plist-get backtrace-view feature))))
+ (setq backtrace-view (plist-put backtrace-view feature value))
+ (goto-char (point-min))
+ ;; Skip the header.
+ (unless (backtrace-get-index)
+ (goto-char (backtrace-get-frame-end)))
+ (while (< (point) (point-max))
+ (backtrace--set-feature feature value)
+ (goto-char (backtrace-get-frame-end)))
+ (if (not index)
+ (goto-char (if at-end (point-max) pos))
+ (goto-char (point-min))
+ (while (and (not (eql index (backtrace-get-index)))
+ (< (point) (point-max)))
+ (goto-char (backtrace-get-frame-end)))))
+ (let ((index (backtrace-get-index)))
+ (unless index
+ (user-error "Not in a stack frame"))
+ (backtrace--set-feature feature
+ (not (plist-get (backtrace-get-view)
feature))))))
+
+(defun backtrace--set-feature (feature value)
+ "Set FEATURE in the view plist of the frame at point to VALUE.
+Reprint the frame with the new view plist."
+ (let ((inhibit-read-only t)
+ (view (copy-sequence (backtrace-get-view)))
+ (index (backtrace-get-index))
+ (min (backtrace-get-frame-start))
+ (max (backtrace-get-frame-end)))
+ (setq view (plist-put view feature value))
+ (delete-region min max)
+ (goto-char min)
+ (backtrace-print-frame (nth index backtrace-frames) view)
+ (add-text-properties min (point)
+ `(backtrace-index ,index backtrace-view ,view))
+ (goto-char min)))
(defun backtrace-expand-ellipsis (button)
"Expand display of the elided form at BUTTON."
@@ -771,6 +792,8 @@ followed by `backtrace-print-frame', once for each stack
frame."
;; (set-buffer-multibyte t)
(setq-local revert-buffer-function #'backtrace-revert)
(setq-local filter-buffer-substring-function #'backtrace--filter-visible)
+ (setq-local indent-line-function 'lisp-indent-line)
+ (setq-local indent-region-function 'lisp-indent-region)
(add-hook 'xref-backend-functions #'backtrace--xref-backend nil t))
(put 'backtrace-mode 'mode-class 'special)
- [Emacs-diffs] branch scratch/backtrace-mode created (now 6b4f622), Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode c7288cc 08/16: Add link in backtraces to position in buffer being evaluated (bug#14081), Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 80d1c52 06/16: Add prefix argument to backtrace-toggle-print-circle,
Gemini Lasswell <=
- [Emacs-diffs] scratch/backtrace-mode b0e53a0 07/16: Add links in backtraces to functions written in C (bug#25393), Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 9f7943a 02/16: Add methods for strings to cl-print, Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 63af8c8 10/16: Change keybinding for backtrace-collapse from '=' to '-', Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode cf2dded 04/16: Always make buttons from function names in backtraces, Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 31cc6ce 13/16: Add a menu for backtrace-mode, Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 1d4502d 12/16: * lisp/emacs-lisp/debug.el (debugger-mode-map): Use easy-menu-define., Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 5d7034a 15/16: Move 'backtrace' from subr.el to backtrace.el, Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 6b4f622 16/16: Give two backtrace-mode commands better names, Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 1ff16de 05/16: Lazily print backtrace frame local variables, Gemini Lasswell, 2018/07/27
- [Emacs-diffs] scratch/backtrace-mode 50197e3 14/16: Add new commands to Edebug backtraces, Gemini Lasswell, 2018/07/27