Function: mh-alias-gecos-name

mh-alias-gecos-name is a byte-compiled function defined in mh-alias.el.gz.

Signature

(mh-alias-gecos-name GECOS-NAME USERNAME COMMA-SEPARATOR)

Documentation

Return a usable address string from a GECOS-NAME and USERNAME.

Use only part of the GECOS-NAME up to the first comma if COMMA-SEPARATOR is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-alias.el.gz
(defun mh-alias-gecos-name (gecos-name username comma-separator)
  "Return a usable address string from a GECOS-NAME and USERNAME.
Use only part of the GECOS-NAME up to the first comma if
COMMA-SEPARATOR is non-nil."
  (let ((res gecos-name))
    ;; Keep only string until first comma if COMMA-SEPARATOR is t.
    (if (and comma-separator
             (string-match "^\\([^,]+\\)," res))
        (setq res (match-string 1 res)))
    ;; Replace "&" with capitalized username
    (if (string-search "&" res)
        (setq res (replace-regexp-in-string "&" (capitalize username) res)))
    ;; Remove " character
    (if (string-search "\"" res)
        (setq res (replace-regexp-in-string "\"" "" res)))
    ;; If empty string, use username instead
    (if (string-equal "" res)
        (setq res username))
    ;; Surround by quotes if doesn't consist of simple characters
    (if (not (string-match "^[ a-zA-Z0-9-]+$" res))
        (setq res (concat "\"" res "\"")))
    res))