aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGemini Lasswell2018-07-21 12:27:32 -0700
committerGemini Lasswell2018-08-03 08:54:08 -0700
commit3cd6a6846b5f8f67216eba61b761a0e1daff7895 (patch)
treeaa3c4afdb3b943234eb6e1eab09e8ac86410fd18 /lisp
parent83af893fc0e7cc87c0fb0626fb48ef96e00b3f8b (diff)
downloademacs-3cd6a6846b5f8f67216eba61b761a0e1daff7895.tar.gz
emacs-3cd6a6846b5f8f67216eba61b761a0e1daff7895.zip
Give two backtrace-mode commands better names
* lisp/emacs-lisp/backtrace.el (backtrace-mode-map): Update bindings and menu items with new function names. (backtrace-collapse, backtrace-pretty-print) (backtrace--collapse, backtrace--pretty-print): Remove functions. (backtrace-single-line, backtrace-multi-line) (backtrace--single-line, backtrace--multi-line): New functions. (backtrace--reformat-sexp): Remove 'error-message' argument. * test/lisp/emacs-lisp/backtrace-tests.el (backtrace-tests--pretty-print-and-collapse): Remove. (backtrace-tests--single-and-multi-line): New test. (backtrace-tests--verify-pp-and-collapse): Remove. (backtrace-tests--verify-single-and-multi-line): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/backtrace.el38
1 files changed, 18 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index d162983c017..f13b43b465c 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -206,8 +206,8 @@ frames where the source code location is known.")
206 (define-key map "#" 'backtrace-toggle-print-circle) 206 (define-key map "#" 'backtrace-toggle-print-circle)
207 (define-key map "s" 'backtrace-goto-source) 207 (define-key map "s" 'backtrace-goto-source)
208 (define-key map "\C-m" 'backtrace-help-follow-symbol) 208 (define-key map "\C-m" 'backtrace-help-follow-symbol)
209 (define-key map "+" 'backtrace-pretty-print) 209 (define-key map "+" 'backtrace-multi-line)
210 (define-key map "-" 'backtrace-collapse) 210 (define-key map "-" 'backtrace-single-line)
211 (define-key map "." 'backtrace-expand-ellipses) 211 (define-key map "." 'backtrace-expand-ellipses)
212 (define-key map [follow-link] 'mouse-face) 212 (define-key map [follow-link] 'mouse-face)
213 (define-key map [mouse-2] 'mouse-select-window) 213 (define-key map [mouse-2] 'mouse-select-window)
@@ -225,9 +225,9 @@ frames where the source code location is known.")
225 :help "Show or hide the local variables for the frame at point"] 225 :help "Show or hide the local variables for the frame at point"]
226 ["Expand \"...\"s" backtrace-expand-ellipses 226 ["Expand \"...\"s" backtrace-expand-ellipses
227 :help "Expand all the abbreviated forms in the current frame"] 227 :help "Expand all the abbreviated forms in the current frame"]
228 ["Show on Multiple Lines" backtrace-pretty-print 228 ["Show on Multiple Lines" backtrace-multi-line
229 :help "Use line breaks and indentation to make a form more readable"] 229 :help "Use line breaks and indentation to make a form more readable"]
230 ["Collapse to Single Line" backtrace-collapse] 230 ["Show on Single Line" backtrace-single-line]
231 "--" 231 "--"
232 ["Go to Source" backtrace-goto-source 232 ["Go to Source" backtrace-goto-source
233 :active (and (backtrace-get-index) 233 :active (and (backtrace-get-index)
@@ -524,37 +524,36 @@ initial state of the Backtrace buffer."
524 (push-button (point))) 524 (push-button (point)))
525 (goto-char next)))))) 525 (goto-char next))))))
526 526
527(defun backtrace-pretty-print () 527(defun backtrace-multi-line ()
528 "Pretty-print the top level s-expression at point." 528 "Show the top level s-expression at point on multiple lines with indentation."
529 (interactive) 529 (interactive)
530 (backtrace--reformat-sexp #'backtrace--pretty-print 530 (backtrace--reformat-sexp #'backtrace--multi-line))
531 "No form here to pretty-print"))
532 531
533(defun backtrace--pretty-print () 532(defun backtrace--multi-line ()
534 "Pretty print the current buffer, then remove the trailing newline." 533 "Pretty print the current buffer, then remove the trailing newline."
535 (set-syntax-table emacs-lisp-mode-syntax-table) 534 (set-syntax-table emacs-lisp-mode-syntax-table)
536 (pp-buffer) 535 (pp-buffer)
537 (goto-char (1- (point-max))) 536 (goto-char (1- (point-max)))
538 (delete-char 1)) 537 (delete-char 1))
539 538
540(defun backtrace-collapse () 539(defun backtrace-single-line ()
541 "Collapse the top level s-expression at point onto one line." 540 "Show the top level s-expression at point on one line."
542 (interactive) 541 (interactive)
543 (backtrace--reformat-sexp #'backtrace--collapse "No form here to collapse")) 542 (backtrace--reformat-sexp #'backtrace--single-line))
544 543
545(defun backtrace--collapse () 544(defun backtrace--single-line ()
546 "Replace line breaks and following indentation with spaces. 545 "Replace line breaks and following indentation with spaces.
547Works on the current buffer." 546Works on the current buffer."
548 (goto-char (point-min)) 547 (goto-char (point-min))
549 (while (re-search-forward "\n[[:blank:]]*" nil t) 548 (while (re-search-forward "\n[[:blank:]]*" nil t)
550 (replace-match " "))) 549 (replace-match " ")))
551 550
552(defun backtrace--reformat-sexp (format-function error-message) 551(defun backtrace--reformat-sexp (format-function)
553 "Reformat the top level sexp at point. 552 "Reformat the top level sexp at point.
554Locate the top level sexp at or following point on the same line, 553Locate the top level sexp at or following point on the same line,
555and reformat it with FORMAT-FUNCTION, preserving the location of 554and reformat it with FORMAT-FUNCTION, preserving the location of
556point within the sexp. If no sexp is found before the end of 555point within the sexp. If no sexp is found before the end of
557the line or buffer, show ERROR-MESSAGE instead. 556the line or buffer, signal an error.
558 557
559FORMAT-FUNCTION will be called without arguments, with the 558FORMAT-FUNCTION will be called without arguments, with the
560current buffer set to a temporary buffer containing only the 559current buffer set to a temporary buffer containing only the
@@ -567,7 +566,7 @@ content of the sexp."
567 nil (point-min)))) 566 nil (point-min))))
568 (unless tag 567 (unless tag
569 (when (or (= end (point-max)) (> end (point-at-eol))) 568 (when (or (= end (point-max)) (> end (point-at-eol)))
570 (user-error error-message)) 569 (user-error "No form here to reformat"))
571 (goto-char end) 570 (goto-char end)
572 (setq pos end 571 (setq pos end
573 end (next-single-property-change pos 'backtrace-form) 572 end (next-single-property-change pos 'backtrace-form)
@@ -752,10 +751,9 @@ Format it according to VIEW."
752 (insert (backtrace--print-to-string 751 (insert (backtrace--print-to-string
753 args (max (truncate (/ backtrace-line-length 5)) 752 args (max (truncate (/ backtrace-line-length 5))
754 (- backtrace-line-length (- (point) beg))))) 753 (- backtrace-line-length (- (point) beg)))))
755 ;; The backtrace-form property is so that 754 ;; The backtrace-form property is so that backtrace-multi-line
756 ;; backtrace-pretty-print will find it. 755 ;; will find it. backtrace-multi-line doesn't do anything
757 ;; backtrace-pretty-print doesn't do anything useful with it, 756 ;; useful with it, just being consistent.
758 ;; just being consistent.
759 (let ((start (point))) 757 (let ((start (point)))
760 (insert "()") 758 (insert "()")
761 (put-text-property start (point) 'backtrace-form t)))) 759 (put-text-property start (point) 'backtrace-form t))))