Function: mh-alias-add-alias

mh-alias-add-alias is an interactive and byte-compiled function defined in mh-alias.el.gz.

Signature

(mh-alias-add-alias ALIAS ADDRESS)

Documentation

Add ALIAS for ADDRESS in personal alias file.

This function prompts you for an alias and address. If the alias exists already, you will have the choice of inserting the new alias before or after the old alias. In the former case, this alias will be used when sending mail to this alias. In the latter case, the alias serves as an additional folder name hint when filing messages.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-alias.el.gz
(defun mh-alias-add-alias (alias address)
  "Add ALIAS for ADDRESS in personal alias file.

This function prompts you for an alias and address.  If the alias
exists already, you will have the choice of inserting the new
alias before or after the old alias.  In the former case, this
alias will be used when sending mail to this alias.  In the latter
case, the alias serves as an additional folder name hint when
filing messages."
  (interactive "P\nP")
  (mh-alias-reload-maybe)
  (setq alias (completing-read "Alias: " mh-alias-alist nil nil alias))
  (if (and address (string-match "^<\\(.*\\)>$" address))
      (setq address (match-string 1 address)))
  (setq address (read-string "Address: " address))
  (if (string-match "^<\\(.*\\)>$" address)
      (setq address (match-string 1 address)))
  (let ((address-alias (mh-alias-address-to-alias address))
        (alias-address (mh-alias-expand alias)))
    (if (string-equal alias-address alias)
        (setq alias-address nil))
    (cond
     ((and (equal alias address-alias)
           (equal address alias-address))
      (message "Already defined as %s" alias-address))
     (address-alias
      (if (y-or-n-p (format "Address has alias %s; set new one? "
                            address-alias))
          (mh-alias-add-alias-to-file alias address)))
     (t
      (mh-alias-add-alias-to-file alias address)))))