Function: comint-update-fence

comint-update-fence is a byte-compiled function defined in comint.el.gz.

Signature

(comint-update-fence)

Documentation

Update read-only status of newline before point.

The fence read-only property is used to indicate that a newline is read-only for no other reason than to "fence off" a following front-sticky read-only region. This is used to implement comint read-only prompts. If the text after a newline changes, the read-only status of that newline may need updating. That is what this function does.

This function does nothing if point is not at the beginning of a line, or is at the beginning of the accessible portion of the buffer. Otherwise, if the character after point has a front-sticky read-only property, then the preceding newline is given a read-only property of fence, unless it already is read-only. If the character after point does not have a front-sticky read-only property, any read-only property of fence on the preceding newline is removed.

Source Code

;; Defined in /usr/src/emacs/lisp/comint.el.gz
;; Support editing with `comint-prompt-read-only' set to t.

(defun comint-update-fence ()
  "Update read-only status of newline before point.
The `fence' read-only property is used to indicate that a newline
is read-only for no other reason than to \"fence off\" a
following front-sticky read-only region.  This is used to
implement comint read-only prompts.  If the text after a newline
changes, the read-only status of that newline may need updating.
That is what this function does.

This function does nothing if point is not at the beginning of a
line, or is at the beginning of the accessible portion of the buffer.
Otherwise, if the character after point has a front-sticky
read-only property, then the preceding newline is given a
read-only property of `fence', unless it already is read-only.
If the character after point does not have a front-sticky
read-only property, any read-only property of `fence' on the
preceding newline is removed."
  (let* ((pt (point)) (lst (get-text-property pt 'front-sticky)))
    (and (bolp)
	 (not (bobp))
         (with-silent-modifications
           (if (and (get-text-property pt 'read-only)
                    (if (listp lst) (memq 'read-only lst) t))
               (unless (get-text-property (1- pt) 'read-only)
                 (put-text-property (1- pt) pt 'read-only 'fence))
             (when (eq (get-text-property (1- pt) 'read-only) 'fence)
               (remove-list-of-text-properties (1- pt) pt '(read-only))))))))