;;; 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
;; 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:
(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"
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
(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))
(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."
(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)
((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)
(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: ")