Function: comint-kill-region

comint-kill-region is an interactive and byte-compiled function defined in comint.el.gz.

Signature

(comint-kill-region BEG END)

Documentation

Like kill-region, but ignore read-only properties, if safe.

This command assumes that the buffer contains read-only
"prompts" which are regions with front-sticky read-only
properties at the beginning of a line, with the preceding newline being read-only to protect the prompt. This is true of the comint prompts if comint-prompt-read-only is non-nil. This command will not delete the region if this would create mutilated or out of place prompts. That is, if any part of a prompt is deleted, the entire prompt must be deleted and all remaining prompts should stay at the beginning of a line. If this is not the case, this command just calls kill-region with all read-only properties intact. The read-only status of newlines is updated using comint-update-fence, if necessary.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-kill-region (beg end)
  "Like `kill-region', but ignore read-only properties, if safe.
This command assumes that the buffer contains read-only
\"prompts\" which are regions with front-sticky read-only
properties at the beginning of a line, with the preceding newline
being read-only to protect the prompt.  This is true of the
comint prompts if `comint-prompt-read-only' is non-nil.  This
command will not delete the region if this would create mutilated
or out of place prompts.  That is, if any part of a prompt is
deleted, the entire prompt must be deleted and all remaining
prompts should stay at the beginning of a line.  If this is not
the case, this command just calls `kill-region' with all
read-only properties intact.  The read-only status of newlines is
updated using `comint-update-fence', if necessary."
  (interactive "r" comint-mode)
  (save-excursion
    (let* ((true-beg (min beg end))
	   (true-end (max beg end))
	   (beg-bolp (progn (goto-char true-beg) (bolp)))
	   (beg-lst (get-text-property true-beg 'front-sticky))
	   (beg-bad (and (get-text-property true-beg 'read-only)
			 (if (listp beg-lst) (memq 'read-only beg-lst) t)))
	   (end-bolp (progn (goto-char true-end) (bolp)))
	   (end-lst (get-text-property true-end 'front-sticky))
	   (end-bad (and (get-text-property true-end 'read-only)
			 (if (listp end-lst) (memq 'read-only end-lst) t))))
      (if (or (and (not beg-bolp) (or beg-bad end-bad))
	      (and (not end-bolp) end-bad))
	  (kill-region beg end)
	(let ((inhibit-read-only t))
	  (kill-region beg end)
	  (comint-update-fence))))))