diff options
| -rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 2 | ||||
| -rw-r--r-- | lisp/international/mule-util.el | 21 |
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. |
| 55 | The optional 3rd arg START-COLUMN, if non-nil, specifies the starting | 56 | The optional 3rd arg START-COLUMN, if non-nil, specifies the starting |
| 56 | column; that means to return the characters occupying columns | 57 | column; 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 | |||
| 72 | end of STR (including any padding) if it extends beyond END-COLUMN, | 73 | end of STR (including any padding) if it extends beyond END-COLUMN, |
| 73 | unless the display width of STR is equal to or less than the display | 74 | unless the display width of STR is equal to or less than the display |
| 74 | width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS | 75 | width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS |
| 75 | defaults to `truncate-string-ellipsis'." | 76 | defaults to `truncate-string-ellipsis'. |
| 77 | |||
| 78 | If ELLIPSIS-TEXT-PROPERTY in non-nil, a too-long string will not | ||
| 79 | be 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. |