;;; message.el --- composing mail and news messages
-;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-;; Free Software Foundation, Inc.
+
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;; 2005 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
(defcustom message-yank-prefix "> "
"*Prefix inserted on the lines of yanked messages.
Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
-See also `message-yank-cited-prefix'."
+See also `message-yank-cited-prefix' and `message-yank-empty-prefix'."
:type 'string
:link '(custom-manual "(message)Insertion Variables")
:group 'message-insertion)
-(defcustom message-yank-add-new-references t
- "Non-nil means new IDs will be added to \"References\" field when an
-article is yanked by the command `message-yank-original' interactively.
-If it is a symbol `message-id-only', only an ID from \"Message-ID\" field
-is used, otherwise IDs extracted from \"References\", \"In-Reply-To\" and
-\"Message-ID\" fields are used."
- :type '(radio (const :tag "Do not add anything" nil)
- (const :tag "From Message-Id, References and In-Reply-To fields" t)
- (const :tag "From only Message-Id field." message-id-only))
- :group 'message-insertion)
-
-(defcustom message-list-references-add-position nil
- "Integer value means position for adding to \"References\" field when
-an article is yanked by the command `message-yank-original' interactively."
- :type '(radio (const :tag "Add to last" nil)
- (integer :tag "Position from last ID"))
- :group 'message-insertion)
-
(defcustom message-yank-cited-prefix ">"
- "*Prefix inserted on cited or empty lines of yanked messages.
+ "*Prefix inserted on cited lines of yanked messages.
Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
-See also `message-yank-prefix'."
+See also `message-yank-prefix' and `message-yank-empty-prefix'."
+ :version "22.1"
+ :type 'string
+ :link '(custom-manual "(message)Insertion Variables")
+ :group 'message-insertion)
+
+(defcustom message-yank-empty-prefix ">"
+ "*Prefix inserted on empty lines of yanked messages.
+See also `message-yank-prefix' and `message-yank-cited-prefix'."
:version "22.1"
:type 'string
:link '(custom-manual "(message)Insertion Variables")
"*Function for citing an original message.
Predefined functions include `message-cite-original' and
`message-cite-original-without-signature'.
-Note that `message-cite-original' uses `mail-citation-hook' if that is non-nil."
+Note that these functions use `mail-citation-hook' if that is non-nil."
:type '(radio (function-item message-cite-original)
(function-item message-cite-original-without-signature)
(function-item mu-cite-original)
:group 'message-insertion)
;;;###autoload
+(defcustom message-indent-citation-function 'message-indent-citation
+ "*Function for modifying a citation just inserted in the mail buffer.
+This can also be a list of functions. Each function can find the
+citation between (point) and (mark t). And each function should leave
+point and mark around the citation text as modified."
+ :type 'function
+ :link '(custom-manual "(message)Insertion Variables")
+ :group 'message-insertion)
+
+;;;###autoload
(defcustom message-suspend-font-lock-when-citing nil
"Non-nil means suspend font-lock'ing while citing an original message.
Some lazy demand-driven fontification tools (or Emacs itself) have a
:type 'boolean
:group 'message-insertion)
-;;;###autoload
-(defcustom message-indent-citation-function 'message-indent-citation
- "*Function for modifying a citation just inserted in the mail buffer.
-This can also be a list of functions. Each function can find the
-citation between (point) and (mark t). And each function should leave
-point and mark around the citation text as modified."
- :type 'function
- :link '(custom-manual "(message)Insertion Variables")
+(defcustom message-yank-add-new-references t
+ "Non-nil means new IDs will be added to \"References\" field when an
+article is yanked by the command `message-yank-original' interactively.
+If it is a symbol `message-id-only', only an ID from \"Message-ID\" field
+is used, otherwise IDs extracted from \"References\", \"In-Reply-To\" and
+\"Message-ID\" fields are used."
+ :type '(radio
+ (const :tag "Do not add anything" nil)
+ (const :tag "From Message-Id, References and In-Reply-To fields" t)
+ (const :tag "From only Message-Id field." message-id-only))
+ :group 'message-insertion)
+
+(defcustom message-list-references-add-position nil
+ "Integer value means position for adding to \"References\" field when
+an article is yanked by the command `message-yank-original' interactively."
+ :type '(radio (const :tag "Add to last" nil)
+ (integer :tag "Position from last ID"))
:group 'message-insertion)
;;;###autoload
:type 'boolean)
(defcustom message-user-fqdn nil
- "*Domain part of Messsage-Ids."
+ "*Domain part of Message-Ids."
:version "22.1"
:group 'message-headers
:link '(custom-manual "(message)News Headers")
(end-of-line -1)))
(unless (= point (point))
(kill-region point (point))
- (insert "\n"))))))
+ (unless (bolp)
+ (insert "\n")))))))
(defun message-newline-and-reformat (&optional arg not-break)
"Insert four newlines, and then reformat if inside quoted text.
Prefix arg means justify as well."
(interactive (list (if current-prefix-arg 'full)))
- (let (quoted point beg end leading-space bolp)
+ (let (quoted point beg end leading-space bolp fill-paragraph-function)
(setq point (point))
(beginning-of-line)
(setq beg (point))
(save-excursion
(goto-char start)
(while (< (point) (mark t))
- (if (or (looking-at ">") (looking-at "^$"))
- (insert message-yank-cited-prefix)
- (insert message-yank-prefix))
+ (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)))
(prog1
t
(delete-windows-on buffer t)
- ; The mark will be set at the end of the article.
- (insert-buffer-substring buffer))))
+ ; Set the mark at the end of the yanked message.
+ (push-mark (save-excursion
+ (insert-buffer-substring buffer)
+ (point))))))
;; Add new IDs to the References field.
(when (and message-yank-add-new-references
(interactive-p))
(push (buffer-name buffer) buffers))))
(nreverse buffers)))
-(defun message-cite-original-without-signature ()
- "Cite function in the standard Message manner."
- (let ((start (point))
- (end (mark t))
- (functions
- (when message-indent-citation-function
- (if (listp message-indent-citation-function)
- message-indent-citation-function
- (list message-indent-citation-function))))
- (message-reply-headers (or message-reply-headers
- (make-mail-header))))
- (mail-header-set-from message-reply-headers
- (save-restriction
- (narrow-to-region
- (point)
- (if (search-forward "\n\n" nil t)
- (1- (point))
- (point-max)))
- (or (message-fetch-field "from")
- "unknown sender")))
- ;; Allow undoing.
- (undo-boundary)
- (goto-char end)
- (when (re-search-backward message-signature-separator start t)
- ;; Also peel off any blank lines before the signature.
- (forward-line -1)
- (while (looking-at "^[ \t]*$")
- (forward-line -1))
- (forward-line 1)
- (delete-region (point) end)
- (unless (search-backward "\n\n" start t)
- ;; Insert a blank line if it is peeled off.
- (insert "\n")))
- (goto-char start)
- (mapc 'funcall functions)
- (when message-citation-line-function
- (unless (bolp)
- (insert "\n"))
- (funcall message-citation-line-function))))
+(eval-when-compile (defvar mail-citation-hook)) ; Compiler directive
-(eval-when-compile (defvar mail-citation-hook)) ;Compiler directive
-(defun message-cite-original ()
- "Cite function in the standard Message manner."
+(defun message-cite-original-1 (strip-signature)
+ "Cite an original message.
+If STRIP-SIGNATURE is non-nil, strips off the signature from the
+original message.
+
+This function uses `mail-citation-hook' if that is non-nil."
(if (and (boundp 'mail-citation-hook)
mail-citation-hook)
(run-hooks 'mail-citation-hook)
(setq x-no-archive (message-fetch-field "x-no-archive")))
(goto-char start)
(mapc 'funcall functions)
+ (when strip-signature
+ ;; Allow undoing.
+ (undo-boundary)
+ (goto-char end)
+ (when (re-search-backward message-signature-separator start t)
+ ;; Also peel off any blank lines before the signature.
+ (forward-line -1)
+ (while (looking-at "^[ \t]*$")
+ (forward-line -1))
+ (forward-line 1)
+ (delete-region (point) end)
+ (unless (search-backward "\n\n" start t)
+ ;; Insert a blank line if it is peeled off.
+ (insert "\n"))))
(when message-citation-line-function
(unless (bolp)
(insert "\n"))
(insert "> [Quoted text removed due to X-No-Archive]\n")
(forward-line -1)))))
+(defun message-cite-original ()
+ "Cite function in the standard Message manner."
+ (message-cite-original-1 nil))
+
+(defun message-cite-original-without-signature ()
+ "Cite function in the standard Message manner.
+This function strips off the signature from the original message."
+ (message-cite-original-1 t))
+
(defun message-insert-citation-line ()
"Insert a simple citation line."
(when message-reply-headers