diff options
| author | Stefan Kangas | 2024-07-01 05:14:25 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2024-07-03 02:08:19 +0200 |
| commit | d64396b8e427e883c47754b133d56cace1219f97 (patch) | |
| tree | 0ff7161635ce6be95c3fdb6e8aae440c235102c3 | |
| parent | b534183135397498e66131fbc5414ef1d445a471 (diff) | |
| download | emacs-d64396b8e427e883c47754b133d56cace1219f97.tar.gz emacs-d64396b8e427e883c47754b133d56cace1219f97.zip | |
Autoload some string functions
These functions are documented in both `(elisp) Creating Strings' and
'M-x shortdoc RET string RET', so users will expect them to be available
without having to require 'subr-x'.
* lisp/emacs-lisp/subr-x.el (string-fill, string-limit, string-pad)
(string-chop-newline): Autoload.
| -rw-r--r-- | lisp/emacs-lisp/subr-x.el | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 699be767ee7..e62a08b7a8b 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el | |||
| @@ -158,6 +158,7 @@ removed." | |||
| 158 | (string-trim (replace-regexp-in-string blank " " string t t) | 158 | (string-trim (replace-regexp-in-string blank " " string t t) |
| 159 | blank blank))) | 159 | blank blank))) |
| 160 | 160 | ||
| 161 | ;;;###autoload | ||
| 161 | (defun string-fill (string length) | 162 | (defun string-fill (string length) |
| 162 | "Try to word-wrap STRING so that no lines are longer than LENGTH. | 163 | "Try to word-wrap STRING so that no lines are longer than LENGTH. |
| 163 | Wrapping is done where there is whitespace. If there are | 164 | Wrapping is done where there is whitespace. If there are |
| @@ -172,6 +173,7 @@ result will have lines that are longer than LENGTH." | |||
| 172 | (fill-region (point-min) (point-max))) | 173 | (fill-region (point-min) (point-max))) |
| 173 | (buffer-string))) | 174 | (buffer-string))) |
| 174 | 175 | ||
| 176 | ;;;###autoload | ||
| 175 | (defun string-limit (string length &optional end coding-system) | 177 | (defun string-limit (string length &optional end coding-system) |
| 176 | "Return a substring of STRING that is (up to) LENGTH characters long. | 178 | "Return a substring of STRING that is (up to) LENGTH characters long. |
| 177 | If STRING is shorter than or equal to LENGTH characters, return the | 179 | If STRING is shorter than or equal to LENGTH characters, return the |
| @@ -253,6 +255,7 @@ than this function." | |||
| 253 | (end (substring string (- (length string) length))) | 255 | (end (substring string (- (length string) length))) |
| 254 | (t (substring string 0 length))))) | 256 | (t (substring string 0 length))))) |
| 255 | 257 | ||
| 258 | ;;;###autoload | ||
| 256 | (defun string-pad (string length &optional padding start) | 259 | (defun string-pad (string length &optional padding start) |
| 257 | "Pad STRING to LENGTH using PADDING. | 260 | "Pad STRING to LENGTH using PADDING. |
| 258 | If PADDING is nil, the space character is used. If not nil, it | 261 | If PADDING is nil, the space character is used. If not nil, it |
| @@ -272,6 +275,7 @@ the string." | |||
| 272 | (start (concat (make-string pad-length (or padding ?\s)) string)) | 275 | (start (concat (make-string pad-length (or padding ?\s)) string)) |
| 273 | (t (concat string (make-string pad-length (or padding ?\s))))))) | 276 | (t (concat string (make-string pad-length (or padding ?\s))))))) |
| 274 | 277 | ||
| 278 | ;;;###autoload | ||
| 275 | (defun string-chop-newline (string) | 279 | (defun string-chop-newline (string) |
| 276 | "Remove the final newline (if any) from STRING." | 280 | "Remove the final newline (if any) from STRING." |
| 277 | (declare (pure t) (side-effect-free t)) | 281 | (declare (pure t) (side-effect-free t)) |