summaryrefslogtreecommitdiff
path: root/lisp/international
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2020-10-04 22:41:36 +0300
committerJuri Linkov <juri@linkov.net>2020-10-04 22:41:36 +0300
commit5ec21155c39aab8a452d190a260e6912d1d9a920 (patch)
tree7636d4f7cd8cd0e16c9bae69654b82f56fb421d4 /lisp/international
parent96a8e846061f255b1a394a5854197aa742dfff84 (diff)
downloademacs-5ec21155c39aab8a452d190a260e6912d1d9a920.tar.gz
Use '…' for ellipsis in truncate-string-to-width by default (bug#41250)
* lisp/international/mule-util.el (truncate-string-ellipsis): Change the default value to nil. (truncate-string-ellipsis): New function. (truncate-string-to-width): Use the value returned from the function 'truncate-string-ellipsis'. * lisp/tab-bar.el (tab-bar-tab-name-truncated): * lisp/tab-line.el (tab-line-tab-name-ellipsis): Take advantage of the improvement of the ellipsis default value in truncate-string-to-width and truncate-string-ellipsis. * doc/lispref/display.texi (Size of Displayed Text): Improve description of truncate-string-ellipsis.
Diffstat (limited to 'lisp/international')
-rw-r--r--lisp/international/mule-util.el21
1 files changed, 17 insertions, 4 deletions
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el
index 660ac58e022..d792b2530c4 100644
--- a/lisp/international/mule-util.el
+++ b/lisp/international/mule-util.el
@@ -44,9 +44,22 @@
(setq i (1+ i)))))
string)
-(defvar truncate-string-ellipsis "..." ;"…"
+(defvar truncate-string-ellipsis nil
"String to use to indicate truncation.
-Serves as default value of ELLIPSIS argument to `truncate-string-to-width'.")
+Serves as default value of ELLIPSIS argument to `truncate-string-to-width'
+returned by the function `truncate-string-ellipsis'.")
+
+(defun truncate-string-ellipsis ()
+ "Return a string to use to indicate truncation.
+Use the value of the variable `truncate-string-ellipsis' when it's non-nil.
+Otherwise, return `…' when it's displayable on the selected frame,
+or `...'. This function needs to be called on every use of
+`truncate-string-to-width' to decide whether the selected frame
+can display the character `…'."
+ (cond
+ (truncate-string-ellipsis)
+ ((char-displayable-p ?…) "…")
+ ("...")))
;;;###autoload
(defun truncate-string-to-width (str end-column
@@ -73,7 +86,7 @@ If ELLIPSIS is non-nil, it should be a string which will replace the
end of STR (including any padding) if it extends beyond END-COLUMN,
unless the display width of STR is equal to or less than the display
width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS
-defaults to `truncate-string-ellipsis'.
+defaults to `truncate-string-ellipsis', or to three dots when it's nil.
If ELLIPSIS-TEXT-PROPERTY is non-nil, a too-long string will not
be truncated, but instead the elided parts will be covered by a
@@ -81,7 +94,7 @@ be truncated, but instead the elided parts will be covered by a
(or start-column
(setq start-column 0))
(when (and ellipsis (not (stringp ellipsis)))
- (setq ellipsis truncate-string-ellipsis))
+ (setq ellipsis (truncate-string-ellipsis)))
(let ((str-len (length str))
(str-width (string-width str))
(ellipsis-width (if ellipsis (string-width ellipsis) 0))