mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-19 12:20:17 -08:00
Add string-chop-newline
* doc/lispref/strings.texi (Creating Strings): Document it. * lisp/emacs-lisp/subr-x.el (string-chop-newline): Add new function.
This commit is contained in:
parent
e967ba3018
commit
f329a3180e
5 changed files with 16 additions and 1 deletions
|
|
@ -181,6 +181,8 @@ There can be any number of :example/:result elements."
|
|||
(string-remove-prefix
|
||||
:no-manual t
|
||||
:eval (string-remove-prefix "foo" "foobar"))
|
||||
(string-chop-newline
|
||||
:eval (string-chop-newline "foo\n"))
|
||||
(string-clean-whitespace
|
||||
:eval (string-clean-whitespace " foo bar "))
|
||||
(string-fill
|
||||
|
|
|
|||
|
|
@ -337,6 +337,10 @@ string."
|
|||
(and (> length 0)
|
||||
(make-string pad-length (or padding ?\s)))))))
|
||||
|
||||
(defun string-chop-newline (string)
|
||||
"Remove the final newline (if any) from STRING."
|
||||
(replace-regexp-in-string "\n\\'" "" string))
|
||||
|
||||
(defun replace-region-contents (beg end replace-fn
|
||||
&optional max-secs max-costs)
|
||||
"Replace the region between BEG and END using REPLACE-FN.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue