[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5ec2115: Use '…' for ellipsis in truncate-string-to-width by def
From: |
Juri Linkov |
Subject: |
master 5ec2115: Use '…' for ellipsis in truncate-string-to-width by default (bug#41250) |
Date: |
Sun, 4 Oct 2020 15:41:59 -0400 (EDT) |
branch: master
commit 5ec21155c39aab8a452d190a260e6912d1d9a920
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
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.
---
doc/lispref/display.texi | 3 ++-
etc/NEWS | 6 ++++++
lisp/international/mule-util.el | 21 +++++++++++++++++----
lisp/tab-bar.el | 10 +++-------
lisp/tab-line.el | 3 +--
5 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 7d1c14c..a70f61e 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1999,7 +1999,8 @@ replace the end of @var{string} (including any padding)
if it extends
beyond @var{width}, unless the display width of @var{string} is equal
to or less than the display width of @var{ellipsis}. If
@var{ellipsis} is non-@code{nil} and not a string, it stands for
-the value of the variable @code{truncate-string-ellipsis}.
+the value of the variable @code{truncate-string-ellipsis}, or
+to three dots when it's nil.
@example
(truncate-string-to-width "\tab\t" 12 4)
diff --git a/etc/NEWS b/etc/NEWS
index 88957fb..d671561 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1475,6 +1475,12 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el.
* Lisp Changes in Emacs 28.1
+++
+** 'truncate-string-ellipsis' uses the character '…' by default.
+Modes that use 'truncate-string-to-width' with non-nil non-string
+argument 'ellipsis', now indicate truncation using '…' when
+the selected frame can display it, and "..." otherwise.
+
++++
*** New command 'make-directory-autoloads'.
This does the same as the old command 'update-directory-autoloads',
but has different semantics: Instead of passing in the output file via
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el
index 660ac58..d792b25 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))
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 9c6b9cb..2604955 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -363,22 +363,18 @@ to `tab-bar-tab-name-truncated'."
:group 'tab-bar
:version "27.1")
-(defvar tab-bar-tab-name-ellipsis nil)
+(defvar tab-bar-tab-name-ellipsis t)
(defun tab-bar-tab-name-truncated ()
"Generate tab name from the buffer of the selected window.
Truncate it to the length specified by `tab-bar-tab-name-truncated-max'.
Append ellipsis `tab-bar-tab-name-ellipsis' in this case."
- (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window))))
- (ellipsis (cond
- (tab-bar-tab-name-ellipsis)
- ((char-displayable-p ?…) "…")
- ("..."))))
+ (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window)))))
(if (< (length tab-name) tab-bar-tab-name-truncated-max)
tab-name
(propertize (truncate-string-to-width
tab-name tab-bar-tab-name-truncated-max nil nil
- ellipsis)
+ tab-bar-tab-name-ellipsis)
'help-echo tab-name))))
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 8da554a..46bf89f 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -240,8 +240,7 @@ to `tab-line-tab-name-truncated-buffer'."
:group 'tab-line
:version "27.1")
-(defvar tab-line-tab-name-ellipsis
- (if (char-displayable-p ?…) "…" "..."))
+(defvar tab-line-tab-name-ellipsis t)
(defun tab-line-tab-name-truncated-buffer (buffer &optional _buffers)
"Generate tab name from BUFFER.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 5ec2115: Use '…' for ellipsis in truncate-string-to-width by default (bug#41250),
Juri Linkov <=