Function: string-chop-newline

string-chop-newline is an autoloaded and byte-compiled function defined in subr-x.el.gz.

Signature

(string-chop-newline STRING)

Documentation

Remove the final newline (if any) from STRING.

Other relevant functions are documented in the string group.

View in manual

Probably introduced at or before Emacs version 28.1.

Shortdoc

;; string
(string-chop-newline "foo\n")
    => "foo"

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/subr-x.el.gz
;;;###autoload
(defun string-chop-newline (string)
  "Remove the final newline (if any) from STRING."
  (declare (pure t) (side-effect-free t))
  (string-remove-suffix "\n" string))