]> code.delx.au - gnu-emacs/blobdiff - lisp/mh-e/mh-alias.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / mh-e / mh-alias.el
index 9dc2871241f46eb8650cf06a0b73e36e8da95768..bb427ef889e73e744f0c78f8a36b1be66dc69303 100644 (file)
@@ -1,7 +1,7 @@
 ;;; mh-alias.el --- MH-E mail alias completion and expansion
 
 ;; Copyright (C) 1994, 1995, 1996, 1997,
-;;  2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;;  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Peter S. Galbraith <psg@debian.org>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -12,7 +12,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -35,6 +35,8 @@
 
 (mh-require-cl)
 
+(require 'goto-addr)
+
 (defvar mh-alias-alist 'not-read
   "Alist of MH aliases.")
 (defvar mh-alias-blind-alist nil
@@ -62,11 +64,6 @@ alias files listed in your \"Aliasfile:\" MH profile component are
 automatically included. You can update the alias list manually using
 \\[mh-alias-reload].")
 
-;; Copy of `goto-address-mail-regexp'.
-(defvar mh-address-mail-regexp
-  "[-a-zA-Z0-9._]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+"
-  "A regular expression probably matching an e-mail address.")
-
 \f
 
 ;;; Alias Loading
@@ -247,6 +244,7 @@ returns the string unchanged if not defined. The same is done here."
              (message "%s" (error-message-string err))
              alias))))
 
+;;;###mh-autoload
 (defun mh-alias-expand (alias)
   "Return expansion for ALIAS.
 Blind aliases or users from /etc/passwd are not expanded."
@@ -343,7 +341,7 @@ NO-COMMA-SWAP is non-nil."
    ((string-match "^\\(.*\\) +<.*>$" string)
     ;; Some name <somename@foo.bar>  -> recurse -> Some name
     (mh-alias-suggest-alias (match-string 1 string) no-comma-swap))
-   ((string-match (concat mh-address-mail-regexp " +(\\(.*\\))$") string)
+   ((string-match (concat goto-address-mail-regexp " +(\\(.*\\))$") string)
     ;; somename@foo.bar (Some name)  -> recurse -> Some name
     (mh-alias-suggest-alias (match-string 1 string) no-comma-swap))
    ((string-match "^\\(Dr\\|Prof\\)\\.? +\\(.*\\)" string)
@@ -595,24 +593,11 @@ filing messages."
 (defun mh-alias-add-address-under-point ()
   "Insert an alias for address under point."
   (interactive)
-  (let ((address (mh-goto-address-find-address-at-point)))
+  (let ((address (goto-address-find-address-at-point)))
     (if address
         (mh-alias-add-alias nil address)
       (message "No email address found under point"))))
 
-;; From goto-addr.el, which we don't want to force-load on users.
-(defun mh-goto-address-find-address-at-point ()
-  "Find e-mail address around or before point.
-
-Then search backwards to beginning of line for the start of an
-e-mail address. If no e-mail address found, return nil."
-  (re-search-backward "[^-_A-z0-9.@]" (mh-line-beginning-position) 'lim)
-  (if (or (looking-at mh-address-mail-regexp) ; already at start
-          (and (re-search-forward mh-address-mail-regexp
-                                  (mh-line-end-position) 'lim)
-               (goto-char (match-beginning 0))))
-      (mh-match-string-no-properties 0)))
-
 (defun mh-alias-apropos (regexp)
   "Show all aliases or addresses that match a regular expression REGEXP."
   (interactive "sAlias regexp: ")