Function: comint-strip-ctrl-m

comint-strip-ctrl-m is an interactive and byte-compiled function defined in comint.el.gz.

Signature

(comint-strip-ctrl-m &optional STRING INTERACTIVE)

Documentation

Strip trailing ^M characters from the current output group.

This function could be on comint-output-filter-functions or bound to a key.

View in manual

Key Bindings

Aliases

shell-strip-ctrl-m (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-strip-ctrl-m (&optional _string interactive)
  "Strip trailing `^M' characters from the current output group.
This function could be on `comint-output-filter-functions' or bound to a key."
  (interactive (list nil t))
  (let ((process (get-buffer-process (current-buffer))))
    (if (not process)
        ;; This function may be used in
        ;; `comint-output-filter-functions', and in that case, if
        ;; there's no process, then we should do nothing.  If
        ;; interactive, report an error.
        (when interactive
          (error "No process in the current buffer"))
      (let ((pmark (process-mark process)))
        (save-excursion
          (condition-case nil
	      (goto-char
	       (if interactive
                   comint-last-input-end comint-last-output-start))
	    (error nil))
          (while (re-search-forward "\r+$" pmark t)
	    (replace-match "" t t)))))))