aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Monnier2023-07-13 19:00:51 -0400
committerStefan Monnier2023-07-13 19:00:51 -0400
commit3ffb99f28f29cd98094f359ea316468572535aa0 (patch)
tree52c98ac7315345ab2a811107d82a90c8711e8195 /test
parentee4cc106b88879c86d08c6fcda06657fb15df0f1 (diff)
downloademacs-3ffb99f28f29cd98094f359ea316468572535aa0.tar.gz
emacs-3ffb99f28f29cd98094f359ea316468572535aa0.zip
cl-print: Put buttons on ellipses
Currently, in *Backtrace* we have a nice behavior for cl-printed objects where they're truncated by default to a manageable size but we can click on the "..." to expand them when needed. The patch below moves that functionality to `cl-print.el` such that it can be enjoyed "everywhere" (bug#64536). It also has the benefit of simplifying the code since `backtrace.el` had to look for ellipses in order to add buttons to them, whereas now we can put the ellipses right when we write them. * lisp/emacs-lisp/cl-print.el (cl-print-object-contents): Improve docstring. (cl-print-expand-ellipsis-function): New var. (cl-print--default-expand-ellipsis): New function. (cl-print-expand-ellipsis): New command. (cl-print-insert-ellipsis): Allow nil instead of 0 to mean "this elides the whole object". (cl-print-ellipsis): Move button type from `backtrace.el`. (cl-print-propertize-ellipsis): Put a button. (cl-print--expand-ellipsis): Rename from `cl-print-expand-ellipsis`. (cl-print-to-string-with-limit): Allow new value t for `limit`. * lisp/emacs-lisp/backtrace.el (backtrace--font-lock-keywords): Simplify. (backtrace--match-ellipsis-in-string): Delete function. (backtrace--change-button-skip): Adjust to new button type name. (backtrace--expand-ellipsis): New function, extracted from `backtrace-expand-ellipsis`. (backtrace-expand-ellipsis): Delete function. (backtrace-ellipsis): Move button type to `cl-print.el`. (backtrace--print-to-string): Don't look for cl-print ellipses any more. (backtrace-mode): Use `backtrace--expand-ellipsis`. * lisp/ielm.el (ielm--expand-ellipsis): New function. (inferior-emacs-lisp-mode): Use it to fill the data when expanded. * test/lisp/emacs-lisp/cl-print-tests.el (cl-print-tests-check-ellipsis-expansion) (cl-print-tests-check-ellipsis-expansion-rx): Adjust to new internal function name.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/cl-print-tests.el5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el b/test/lisp/emacs-lisp/cl-print-tests.el
index af94dae310c..3073a42e39d 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -25,6 +25,7 @@
25;;; Code: 25;;; Code:
26 26
27(require 'ert) 27(require 'ert)
28(require 'cl-print)
28 29
29(cl-defstruct (cl-print-tests-struct 30(cl-defstruct (cl-print-tests-struct
30 (:constructor cl-print-tests-con)) 31 (:constructor cl-print-tests-con))
@@ -113,7 +114,7 @@
113 (should pos) 114 (should pos)
114 (setq value (get-text-property pos 'cl-print-ellipsis result)) 115 (setq value (get-text-property pos 'cl-print-ellipsis result))
115 (should (equal expected result)) 116 (should (equal expected result))
116 (should (equal expanded (with-output-to-string (cl-print-expand-ellipsis 117 (should (equal expanded (with-output-to-string (cl-print--expand-ellipsis
117 value nil)))))) 118 value nil))))))
118 119
119(defun cl-print-tests-check-ellipsis-expansion-rx (obj expected expanded) 120(defun cl-print-tests-check-ellipsis-expansion-rx (obj expected expanded)
@@ -122,7 +123,7 @@
122 (value (get-text-property pos 'cl-print-ellipsis result))) 123 (value (get-text-property pos 'cl-print-ellipsis result)))
123 (should (string-match expected result)) 124 (should (string-match expected result))
124 (should (string-match expanded (with-output-to-string 125 (should (string-match expanded (with-output-to-string
125 (cl-print-expand-ellipsis value nil)))))) 126 (cl-print--expand-ellipsis value nil))))))
126 127
127(ert-deftest cl-print-tests-print-to-string-with-limit () 128(ert-deftest cl-print-tests-print-to-string-with-limit ()
128 (let* ((thing10 (make-list 10 'a)) 129 (let* ((thing10 (make-list 10 'a))