Function: mh-insert-auto-fields

mh-insert-auto-fields is an autoloaded, interactive and byte-compiled function defined in mh-comp.el.gz.

Signature

(mh-insert-auto-fields &optional NON-INTERACTIVE)

Documentation

Insert custom fields if recipient is found in mh-auto-fields-list.

Once the header contains one or more recipients, you may run this command to insert these fields manually. However, if you use this command, the automatic insertion when the message is sent is disabled.

In a program, set buffer-local mh-insert-auto-fields-done-local if header fields were added. If NON-INTERACTIVE is non-nil, perform actions quietly and only if mh-insert-auto-fields-done-local is nil. Return t if fields added; otherwise return nil.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-comp.el.gz
;;;###mh-autoload
(defun mh-insert-auto-fields (&optional non-interactive)
  "Insert custom fields if recipient is found in `mh-auto-fields-list'.

Once the header contains one or more recipients, you may run this
command to insert these fields manually. However, if you use this
command, the automatic insertion when the message is sent is
disabled.

In a program, set buffer-local `mh-insert-auto-fields-done-local'
if header fields were added. If NON-INTERACTIVE is non-nil,
perform actions quietly and only if
`mh-insert-auto-fields-done-local' is nil. Return t if fields
added; otherwise return nil."
  (interactive)
  (when (or (not non-interactive)
            (not mh-insert-auto-fields-done-local))
    (save-excursion
      (when (and (or (mh-goto-header-field "To:")
                     (mh-goto-header-field "cc:")))
        (let ((list mh-auto-fields-list)
              (fields-inserted nil))
          (while list
            (let ((regexp (nth 0 (car list)))
                  (entries (nth 1 (car list))))
              (when (mh-regexp-in-field-p regexp "To:" "cc:")
                (setq mh-insert-auto-fields-done-local t)
                (setq fields-inserted t)
                (if (not non-interactive)
                    (message "Fields for %s added" regexp))
                (let ((entry-list entries))
                  (while entry-list
                    (let ((field (caar entry-list))
                          (value (cdar entry-list)))
                      (cond
                       ((equal ":identity" field)
                        (when
                            ;;(and (not mh-identity-local)
                            ;; Bug 1204506.  But do we need to be able
                            ;; to set an identity manually that won't be
                            ;; overridden by mh-insert-auto-fields?
                            (assoc value mh-identity-list)
                          ;;)
                          (mh-insert-identity value)))
                       (t
                        (mh-modify-header-field field value
                                                (equal field "From")))))
                    (setq entry-list (cdr entry-list))))))
            (setq list (cdr list)))
          fields-inserted)))))