comparison lisp/mh-e/mh-alias.el @ 69031:4cb528cc4c04

* mh-alias.el (mh-address-mail-regexp) (mh-goto-address-find-address-at-point): Delete copies from goto-addr.el. (mh-alias-suggest-alias): Use goto-address-mail-regexp instead of mh-address-mail-regexp. (mh-alias-add-address-under-point): Use goto-address-find-address-at-point instead of mh-goto-address-find-address-at-point. * mh-e.el (mh-show-use-goto-addr-flag): Delete. * mh-show.el (mh-show-mode): Mention goto-address-highlight-p in docstring. (mh-show-addr): Call goto-address unconditionally. User should use goto-address-highlight-p instead of mh-show-use-goto-addr-flag.
author Bill Wohler <wohler@newt.com>
date Mon, 20 Feb 2006 01:24:38 +0000
parents 7daec5f4a289
children e3694f1cb928 d1c5430c5bff
comparison
equal deleted inserted replaced
69030:0c3b91a536ab 69031:4cb528cc4c04
32 ;;; Code: 32 ;;; Code:
33 33
34 (require 'mh-e) 34 (require 'mh-e)
35 35
36 (mh-require-cl) 36 (mh-require-cl)
37
38 (require 'goto-addr)
37 39
38 (defvar mh-alias-alist 'not-read 40 (defvar mh-alias-alist 'not-read
39 "Alist of MH aliases.") 41 "Alist of MH aliases.")
40 (defvar mh-alias-blind-alist nil 42 (defvar mh-alias-blind-alist nil
41 "Alist of MH aliases that are blind lists.") 43 "Alist of MH aliases that are blind lists.")
59 If these files are modified, they are automatically reread. This list 61 If these files are modified, they are automatically reread. This list
60 need include only system aliases and the passwd file, since personal 62 need include only system aliases and the passwd file, since personal
61 alias files listed in your \"Aliasfile:\" MH profile component are 63 alias files listed in your \"Aliasfile:\" MH profile component are
62 automatically included. You can update the alias list manually using 64 automatically included. You can update the alias list manually using
63 \\[mh-alias-reload].") 65 \\[mh-alias-reload].")
64
65 ;; Copy of `goto-address-mail-regexp'.
66 (defvar mh-address-mail-regexp
67 "[-a-zA-Z0-9._]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+"
68 "A regular expression probably matching an e-mail address.")
69 66
70 67
71 68
72 ;;; Alias Loading 69 ;;; Alias Loading
73 70
341 ;; "Some name" <somename@foo.bar> -> recurse -> "Some name" 338 ;; "Some name" <somename@foo.bar> -> recurse -> "Some name"
342 (mh-alias-suggest-alias (match-string 1 string) no-comma-swap)) 339 (mh-alias-suggest-alias (match-string 1 string) no-comma-swap))
343 ((string-match "^\\(.*\\) +<.*>$" string) 340 ((string-match "^\\(.*\\) +<.*>$" string)
344 ;; Some name <somename@foo.bar> -> recurse -> Some name 341 ;; Some name <somename@foo.bar> -> recurse -> Some name
345 (mh-alias-suggest-alias (match-string 1 string) no-comma-swap)) 342 (mh-alias-suggest-alias (match-string 1 string) no-comma-swap))
346 ((string-match (concat mh-address-mail-regexp " +(\\(.*\\))$") string) 343 ((string-match (concat goto-address-mail-regexp " +(\\(.*\\))$") string)
347 ;; somename@foo.bar (Some name) -> recurse -> Some name 344 ;; somename@foo.bar (Some name) -> recurse -> Some name
348 (mh-alias-suggest-alias (match-string 1 string) no-comma-swap)) 345 (mh-alias-suggest-alias (match-string 1 string) no-comma-swap))
349 ((string-match "^\\(Dr\\|Prof\\)\\.? +\\(.*\\)" string) 346 ((string-match "^\\(Dr\\|Prof\\)\\.? +\\(.*\\)" string)
350 ;; Strip out title 347 ;; Strip out title
351 (mh-alias-suggest-alias (match-string 2 string) no-comma-swap)) 348 (mh-alias-suggest-alias (match-string 2 string) no-comma-swap))
593 (mh-alias-add-alias alias address)))) 590 (mh-alias-add-alias alias address))))
594 591
595 (defun mh-alias-add-address-under-point () 592 (defun mh-alias-add-address-under-point ()
596 "Insert an alias for address under point." 593 "Insert an alias for address under point."
597 (interactive) 594 (interactive)
598 (let ((address (mh-goto-address-find-address-at-point))) 595 (let ((address (goto-address-find-address-at-point)))
599 (if address 596 (if address
600 (mh-alias-add-alias nil address) 597 (mh-alias-add-alias nil address)
601 (message "No email address found under point")))) 598 (message "No email address found under point"))))
602
603 ;; From goto-addr.el, which we don't want to force-load on users.
604 (defun mh-goto-address-find-address-at-point ()
605 "Find e-mail address around or before point.
606
607 Then search backwards to beginning of line for the start of an
608 e-mail address. If no e-mail address found, return nil."
609 (re-search-backward "[^-_A-z0-9.@]" (mh-line-beginning-position) 'lim)
610 (if (or (looking-at mh-address-mail-regexp) ; already at start
611 (and (re-search-forward mh-address-mail-regexp
612 (mh-line-end-position) 'lim)
613 (goto-char (match-beginning 0))))
614 (mh-match-string-no-properties 0)))
615 599
616 (defun mh-alias-apropos (regexp) 600 (defun mh-alias-apropos (regexp)
617 "Show all aliases or addresses that match a regular expression REGEXP." 601 "Show all aliases or addresses that match a regular expression REGEXP."
618 (interactive "sAlias regexp: ") 602 (interactive "sAlias regexp: ")
619 (if mh-alias-local-users 603 (if mh-alias-local-users