diff options
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/shortdoc.el | 2 | ||||
-rw-r--r-- | lisp/emacs-lisp/subr-x.el | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index df31b0aaf1f..9bd06636f4d 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -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 diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 78d0b054b35..80d4cb9b650 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -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. |