(cl-defmethod cl-print-object ((object string) stream)
(unless stream (setq stream standard-output))
(let* ((has-properties (or (text-properties-at 0 object)
- (next-property-change 0 object)))
- (len (length object))
- (limit (if (natnump print-length) (min print-length len) len)))
+ (next-property-change 0 object))))
(if (and has-properties
cl-print--depth
(natnump print-level)
(> cl-print--depth print-level))
(cl-print-insert-ellipsis object nil stream)
- ;; Print all or part of the string
+ ;; Print the string.
(when has-properties
(princ "#(" stream))
- (if (= limit len)
- (prin1 (if has-properties (substring-no-properties object) object)
- stream)
- (let ((part (concat (substring-no-properties object 0 limit) "...")))
- (prin1 part stream)
- (when (bufferp stream)
- (with-current-buffer stream
- (cl-print-propertize-ellipsis object limit
- (- (point) 4)
- (- (point) 1) stream)))))
+ (prin1 (if has-properties (substring-no-properties object) object)
+ stream)
;; Print the property list.
(when has-properties
(cl-print--string-props object 0 stream)
(cl-print-tests-check-ellipsis-expansion
[a [b [c [d [e]]]]] "[a [b [c ...]]]" "[d [e]]")))
-(ert-deftest cl-print-tests-ellipsis-string ()
- "Ellipsis expansion works in strings."
- (let ((print-length 4)
- (print-level 3))
- (cl-print-tests-check-ellipsis-expansion
- "abcdefg" "\"abcd...\"" "efg")
- (cl-print-tests-check-ellipsis-expansion
- "abcdefghijk" "\"abcd...\"" "efgh...")
- (cl-print-tests-check-ellipsis-expansion
- '(1 (2 (3 #("abcde" 0 5 (test t)))))
- "(1 (2 (3 ...)))" "#(\"abcd...\" 0 5 (test t))")
- (cl-print-tests-check-ellipsis-expansion
- #("abcd" 0 1 (bold t) 1 2 (invisible t) 3 4 (italic t))
- "#(\"abcd\" 0 1 (bold t) ...)" "1 2 (invisible t) ...")))
-
(ert-deftest cl-print-tests-ellipsis-struct ()
"Ellipsis expansion works in structures."
(let ((print-length 4)
;; Print something which needs to be abbreviated and which can be.
(should (< (length (cl-print-to-string-with-limit #'cl-prin1 thing100 100))
- 100
+ 150 ;; 100. The LIMIT argument is advisory rather than absolute.
(length (cl-prin1-to-string thing100))))
;; Print something resistant to easy abbreviation.