emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5c86a53 2/2: Improve the string-limit doc string


From: Lars Ingebrigtsen
Subject: master 5c86a53 2/2: Improve the string-limit doc string
Date: Wed, 23 Dec 2020 01:59:35 -0500 (EST)

branch: master
commit 5c86a5329664cd5fd3b81fe991c8d7dc18815e07
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Improve the string-limit doc string
    
    * lisp/emacs-lisp/subr-x.el (string-limit): Mention
    truncate-string-to-width in the doc string.
---
 lisp/emacs-lisp/shortdoc.el | 3 +++
 lisp/emacs-lisp/subr-x.el   | 6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el
index e9e1be1..0067495 100644
--- a/lisp/emacs-lisp/shortdoc.el
+++ b/lisp/emacs-lisp/shortdoc.el
@@ -147,6 +147,9 @@ There can be any number of :example/:result elements."
    :eval (string-limit "foobar" 3)
    :eval (string-limit "foobar" 3 t)
    :eval (string-limit "foobar" 10))
+  (truncate-string-to-width
+   :eval (truncate-string-to-width "foobar" 3)
+   :eval (truncate-string-to-width "你好bar" 5))
   (split-string
    :eval (split-string "foo bar")
    :eval (split-string "|foo|bar|" "|")
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 8a9424c..7e17a34 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -293,7 +293,11 @@ is returned unchanged.
 
 If STRING is longer than LENGTH, return a substring consisting of
 the first LENGTH characters of STRING.  If END is non-nil, return
-the last LENGTH characters instead."
+the last LENGTH characters instead.
+
+When shortening strings for display purposes,
+`truncate-string-to-width' is almost always a better alternative
+than this function."
   (unless (natnump length)
     (signal 'wrong-type-argument (list 'natnump length)))
   (cond



reply via email to

[Prev in Thread] Current Thread [Next in Thread]