Function: erc-display-prompt

erc-display-prompt is a byte-compiled function defined in erc.el.gz.

Signature

(erc-display-prompt &optional BUFFER POS PROMPT FACE)

Documentation

Display PROMPT in BUFFER at position POS.

Display an ERC prompt in BUFFER.

If PROMPT is nil, one is constructed with the function erc-prompt(var)/erc-prompt(fun). If BUFFER is nil, the current-buffer is used. If POS is nil, PROMPT will be displayed at point. If FACE is non-nil, it will be used to propertize the prompt. If it is nil, erc-prompt-face will be used.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-display-prompt (&optional buffer pos prompt face)
  "Display PROMPT in BUFFER at position POS.
Display an ERC prompt in BUFFER.

If PROMPT is nil, one is constructed with the function `erc-prompt'.
If BUFFER is nil, the `current-buffer' is used.
If POS is nil, PROMPT will be displayed at `point'.
If FACE is non-nil, it will be used to propertize the prompt.  If it is nil,
`erc-prompt-face' will be used."
  (let* ((prompt (or prompt (erc-prompt)))
         (l (length prompt))
         (ob (current-buffer)))
    ;; We cannot use save-excursion because we move point, therefore
    ;; we resort to the ol' ob trick to restore this.
    (when (and buffer (bufferp buffer))
      (set-buffer buffer))

    ;; now save excursion again to store where point and mark are
    ;; in the current buffer
    (save-excursion
      (setq pos (or pos (point)))
      (goto-char pos)
      (when (> l 0)
        ;; Do not extend the text properties when typing at the end
        ;; of the prompt, but stuff typed in front of the prompt
        ;; shall remain part of the prompt.
        (setq prompt (propertize prompt
                                 'rear-nonsticky t
                                 'erc-prompt t
                                 'field t
                                 'front-sticky t
                                 'read-only t))
        (erc-put-text-property 0 (1- (length prompt))
                               'font-lock-face (or face 'erc-prompt-face)
                               prompt)
        (insert prompt))
      ;; Set the input marker
      (set-marker erc-input-marker (point)))

    ;; Now we are back at the old position.  If the prompt was
    ;; inserted here or before us, advance point by the length of
    ;; the prompt.
    (when (or (not pos) (<= (point) pos))
      (forward-char l))
    ;; Clear the undo buffer now, so the user can undo his stuff,
    ;; but not the stuff we did. Sneaky!
    (setq buffer-undo-list nil)
    (set-buffer ob)))