aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/tabulated-list.el2
-rw-r--r--lisp/international/mule-util.el21
2 files changed, 18 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index ade60285883..66a859f56ce 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -544,7 +544,7 @@ Return the column number after insertion."
544 (when (and not-last-col 544 (when (and not-last-col
545 (> label-width available-space) 545 (> label-width available-space)
546 (setq label (truncate-string-to-width 546 (setq label (truncate-string-to-width
547 label available-space nil nil t) 547 label available-space nil nil t t)
548 label-width available-space))) 548 label-width available-space)))
549 (setq label (bidi-string-mark-left-to-right label)) 549 (setq label (bidi-string-mark-left-to-right label))
550 (when (and right-align (> width label-width)) 550 (when (and right-align (> width label-width))
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el
index 19d6d165cfd..a1603e06717 100644
--- a/lisp/international/mule-util.el
+++ b/lisp/international/mule-util.el
@@ -50,7 +50,8 @@ Serves as default value of ELLIPSIS argument to `truncate-string-to-width'.")
50 50
51;;;###autoload 51;;;###autoload
52(defun truncate-string-to-width (str end-column 52(defun truncate-string-to-width (str end-column
53 &optional start-column padding ellipsis) 53 &optional start-column padding ellipsis
54 ellipsis-text-property)
54 "Truncate string STR to end at column END-COLUMN. 55 "Truncate string STR to end at column END-COLUMN.
55The optional 3rd arg START-COLUMN, if non-nil, specifies the starting 56The optional 3rd arg START-COLUMN, if non-nil, specifies the starting
56column; that means to return the characters occupying columns 57column; that means to return the characters occupying columns
@@ -72,7 +73,11 @@ If ELLIPSIS is non-nil, it should be a string which will replace the
72end of STR (including any padding) if it extends beyond END-COLUMN, 73end of STR (including any padding) if it extends beyond END-COLUMN,
73unless the display width of STR is equal to or less than the display 74unless the display width of STR is equal to or less than the display
74width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS 75width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS
75defaults to `truncate-string-ellipsis'." 76defaults to `truncate-string-ellipsis'.
77
78If ELLIPSIS-TEXT-PROPERTY in non-nil, a too-long string will not
79be truncated, but instead the elided parts will be covered by a
80`display' text property showing the ellipsis."
76 (or start-column 81 (or start-column
77 (setq start-column 0)) 82 (setq start-column 0))
78 (when (and ellipsis (not (stringp ellipsis))) 83 (when (and ellipsis (not (stringp ellipsis)))
@@ -113,8 +118,16 @@ defaults to `truncate-string-ellipsis'."
113 idx last-idx)) 118 idx last-idx))
114 (when (and padding (< column end-column)) 119 (when (and padding (< column end-column))
115 (setq tail-padding (make-string (- end-column column) padding)))) 120 (setq tail-padding (make-string (- end-column column) padding))))
116 (concat head-padding (substring str from-idx idx) 121 (if (and ellipsis-text-property
117 tail-padding ellipsis)))) 122 (not (equal ellipsis ""))
123 idx)
124 ;; Use text properties for the ellipsis.
125 (concat head-padding
126 (substring str from-idx idx)
127 (propertize (substring str idx) 'display (or ellipsis "")))
128 ;; (Possibly) chop off bits of the string.
129 (concat head-padding (substring str from-idx idx)
130 tail-padding ellipsis)))))
118 131
119 132
120;;; Nested alist handler. 133;;; Nested alist handler.