Function: sc-attribs-extract-namestring

sc-attribs-extract-namestring is a byte-compiled function defined in supercite.el.gz.

Signature

(sc-attribs-extract-namestring FROM)

Documentation

Extract the name string from FROM.

This should be the author's full name minus an optional title.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/supercite.el.gz
(defun sc-attribs-extract-namestring (from)
  "Extract the name string from FROM.
This should be the author's full name minus an optional title."
  ;; FIXME: we probably should use mail-extract-address-components.
  (let ((namestring
	 (or
	  ;; If there is a <...> in the name,
	  ;; treat everything before that as the full name.
	  ;; Even if it contains parens, use the whole thing.
	  ;; On the other hand, we do look for quotes in the usual way.
	  (and (string-match " *<.*>" from 0)
	       (let ((before-angles
		      (sc-name-substring from 0 (match-beginning 0) 0)))
		 (if (string-match "\".*\"" before-angles 0)
		     (sc-name-substring
		      before-angles (match-beginning 0) (match-end 0) 1)
		   before-angles)))
	  (sc-name-substring
	   from (string-match "(.*)" from 0) (match-end 0) 1)
	  (sc-name-substring
	   from (string-match "\".*\"" from 0) (match-end 0) 1)
	  (sc-name-substring
	   from (string-match "\\([-.[:alnum:]_]+\\s +\\)+<" from 0)
	   (match-end 1) 0)
	  (sc-attribs-emailname from))))
    ;; strip off any leading or trailing whitespace
    (if namestring
	(let ((bos 0)
	      (eos (1- (length namestring))))
	  (while (and (<= bos eos)
		      (memq (aref namestring bos) '(32 ?\t)))
	    (setq bos (1+ bos)))
	  (while (and (> eos bos)
		      (memq (aref namestring eos) '(32 ?\t)))
	    (setq eos (1- eos)))
	  (substring namestring bos (1+ eos))))))