Function: shell-command-save-pos-or-erase
shell-command-save-pos-or-erase is a byte-compiled function defined in
simple.el.gz.
Signature
(shell-command-save-pos-or-erase &optional OUTPUT-TO-CURRENT-BUFFER)
Documentation
Store a buffer position or erase the buffer.
Optional argument OUTPUT-TO-CURRENT-BUFFER, if non-nil, means that the output of the shell command goes to the caller current buffer.
See shell-command-dont-erase-buffer.
Probably introduced at or before Emacs version 27.1.
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun shell-command-save-pos-or-erase (&optional output-to-current-buffer)
"Store a buffer position or erase the buffer.
Optional argument OUTPUT-TO-CURRENT-BUFFER, if non-nil, means that the output
of the shell command goes to the caller current buffer.
See `shell-command-dont-erase-buffer'."
(let ((sym shell-command-dont-erase-buffer)
pos)
(setq buffer-read-only nil)
;; Setting buffer-read-only to nil doesn't suffice
;; if some text has a non-nil read-only property,
;; which comint sometimes adds for prompts.
(setq pos
(cond ((eq sym 'save-point)
(if (not output-to-current-buffer)
(point)))
((eq sym 'beg-last-out)
(if (not output-to-current-buffer)
(point-max)))
((or (eq sym 'erase)
(and (null sym) (not output-to-current-buffer)))
(let ((inhibit-read-only t))
(erase-buffer) nil))))
(when pos
(goto-char (point-max))
(push (cons (current-buffer) pos)
shell-command-saved-pos))))