Function: message-indent-citation

message-indent-citation is a byte-compiled function defined in message.el.gz.

Signature

(message-indent-citation &optional START END YANK-ONLY)

Documentation

Modify text just inserted from a message to be cited.

The inserted text should be the region. When this function returns, the region is again around the modified text.

Normally, indent each nonblank line message-indentation-spaces spaces. However, if message-yank-prefix is non-nil, insert that prefix on each line.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-indent-citation (&optional start end yank-only)
  "Modify text just inserted from a message to be cited.
The inserted text should be the region.
When this function returns, the region is again around the modified text.

Normally, indent each nonblank line `message-indentation-spaces' spaces.
However, if `message-yank-prefix' is non-nil, insert that prefix on each line."
  (unless start (setq start (point)))
  (unless yank-only
    ;; Remove unwanted headers.
    (when message-ignored-cited-headers
      (let (all-removed)
	(save-restriction
	  (narrow-to-region
	   (goto-char start)
	   (if (search-forward "\n\n" nil t)
	       (1- (point))
	     (point)))
	  (message-remove-header message-ignored-cited-headers t)
	  (when (= (point-min) (point-max))
	    (setq all-removed t))
	  (goto-char (point-max)))
	(if all-removed
	    (goto-char start)
	  (forward-line 1))))
    ;; Delete blank lines at the start of the cited text.
    (while (and (eolp) (not (eobp)))
      (delete-line))
    ;; Delete blank lines at the end of the buffer.
    (goto-char (point-max))
    (unless (eq (preceding-char) ?\n)
      (insert "\n"))
    (while (and (zerop (forward-line -1))
		(looking-at "$"))
      (delete-line)))
  ;; Do the indentation.
  (if (null message-yank-prefix)
      (indent-rigidly start (or end (mark t)) message-indentation-spaces)
    (save-excursion
      (goto-char start)
      (while (< (point) (or end (mark t)))
	(cond ((looking-at ">")
	       (insert message-yank-cited-prefix))
	      ((looking-at "^$")
	       (insert message-yank-empty-prefix))
	      (t
	       (insert message-yank-prefix)))
	(forward-line 1))))
  (goto-char start))