]> code.delx.au - gnu-emacs/blobdiff - lisp/mh-e/mh-alias.el
Fix typos.
[gnu-emacs] / lisp / mh-e / mh-alias.el
index 23af886c32053ceb74f334294f1dd963694fbbe2..ef96a90c5ab49efba3ed36ad92fc5ce681fc78af 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>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,9 +21,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -35,6 +33,8 @@
 
 (mh-require-cl)
 
+(require 'goto-addr)
+
 (defvar mh-alias-alist 'not-read
   "Alist of MH aliases.")
 (defvar mh-alias-blind-alist nil
   "Alist of aliases extracted from passwd file and their expansions.")
 (defvar mh-alias-tstamp nil
   "Time aliases were last loaded.")
-(defvar mh-alias-read-address-map nil)
-(unless mh-alias-read-address-map
-  (setq mh-alias-read-address-map
-        (copy-keymap minibuffer-local-completion-map))
-  (define-key mh-alias-read-address-map
-    "," 'mh-alias-minibuffer-confirm-address)
-  (define-key mh-alias-read-address-map " " 'self-insert-command))
+(defvar mh-alias-read-address-map
+  (let ((map (copy-keymap minibuffer-local-completion-map)))
+    (define-key map "," 'mh-alias-minibuffer-confirm-address)
+    (define-key map " " 'self-insert-command)
+    map))
 
 (defvar mh-alias-system-aliases
   '("/etc/nmh/MailAliases" "/etc/mh/MailAliases"
@@ -62,11 +60,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
@@ -125,10 +118,10 @@ COMMA-SEPARATOR is non-nil."
         (setq res (match-string 1 res)))
     ;; Replace "&" with capitalized username
     (if (string-match "&" res)
-        (setq res (replace-regexp-in-string "&" (capitalize username) res)))
+        (setq res (mh-replace-regexp-in-string "&" (capitalize username) res)))
     ;; Remove " character
     (if (string-match "\"" res)
-        (setq res (replace-regexp-in-string "\"" "" res)))
+        (setq res (mh-replace-regexp-in-string "\"" "" res)))
     ;; If empty string, use username instead
     (if (string-equal "" res)
         (setq res username))
@@ -247,6 +240,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."
@@ -258,8 +252,8 @@ Blind aliases or users from /etc/passwd are not expanded."
    (t
     (mh-alias-ali alias))))
 
-(require 'crm nil t)                   ; completing-read-multiple
-(require 'multi-prompt nil t)
+(mh-require 'crm nil t)                 ; completing-read-multiple
+(mh-require 'multi-prompt nil t)
 
 ;;;###mh-autoload
 (defun mh-read-address (prompt)
@@ -343,7 +337,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 +589,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.@]" (line-beginning-position) 'lim)
-  (if (or (looking-at mh-address-mail-regexp) ; already at start
-          (and (re-search-forward mh-address-mail-regexp
-                                  (line-end-position) 'lim)
-               (goto-char (match-beginning 0))))
-      (match-string-no-properties 0)))
-
 (defun mh-alias-apropos (regexp)
   "Show all aliases or addresses that match a regular expression REGEXP."
   (interactive "sAlias regexp: ")