2001-07-15 16:15:35 +00:00
|
|
|
|
;;; mailabbrev.el --- abbrev-expansion of mail aliases
|
1992-09-15 19:38:02 +00:00
|
|
|
|
|
2005-08-06 19:51:42 +00:00
|
|
|
|
;; Copyright (C) 1985, 1986, 1987, 1992, 1993, 1996, 1997, 2000, 2002,
|
|
|
|
|
;; 2003, 2004, 2005 Free Software Foundation, Inc.
|
1992-09-15 19:38:02 +00:00
|
|
|
|
|
2000-02-02 16:00:17 +00:00
|
|
|
|
;; Author: Jamie Zawinski <jwz@lucid.com>, now <jwz@jwz.org>
|
|
|
|
|
;; Maintainer: FSF
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;; Created: 19 Oct 90
|
|
|
|
|
;; Keywords: mail
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; 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.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; 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
|
2005-07-04 17:55:18 +00:00
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1996-05-26 23:12:01 +00:00
|
|
|
|
;; This file ensures that, when the point is in a To:, CC:, BCC:, or From:
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; field, word-abbrevs are defined for each of your mail aliases. These
|
|
|
|
|
;; aliases will be defined from your .mailrc file (or the file specified by
|
2003-09-30 12:44:53 +00:00
|
|
|
|
;; `mail-personal-alias-file') if it exists. Your mail aliases will
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; expand any time you type a word-delimiter at the end of an abbreviation.
|
|
|
|
|
;;
|
|
|
|
|
;; What you see is what you get: if mailabbrev is in use when you type
|
|
|
|
|
;; a name, and the name does not expand, you know it is not an abbreviation.
|
|
|
|
|
;; However, if you yank abbreviations into the headers
|
|
|
|
|
;; in a way that bypasses the check for abbreviations,
|
|
|
|
|
;; they are expanded (but not visibly) when you send the message.
|
|
|
|
|
;;
|
|
|
|
|
;; Your mail alias abbrevs will be in effect only when the point is in an
|
|
|
|
|
;; appropriate header field. When in the body of the message, or other
|
|
|
|
|
;; header fields, the mail aliases will not expand. Rather, the normal
|
2002-04-19 00:08:19 +00:00
|
|
|
|
;; mode-specific abbrev table will be used if
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; defined. So if you use mail-mode specific abbrevs, this code will not
|
|
|
|
|
;; adversely affect you. You can control which header fields the abbrevs
|
|
|
|
|
;; are used in by changing the variable mail-abbrev-mode-regexp.
|
|
|
|
|
;;
|
|
|
|
|
;; If auto-fill mode is on, abbrevs will wrap at commas instead of at word
|
|
|
|
|
;; boundaries; also, header continuation-lines will be properly indented.
|
|
|
|
|
;;
|
2000-05-03 19:25:07 +00:00
|
|
|
|
;; You can also insert a mail alias with mail-abbrev-insert-alias
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; (bound to C-c C-a), which prompts you for an alias (with completion)
|
|
|
|
|
;; and inserts its expansion at point.
|
|
|
|
|
;;
|
|
|
|
|
;; This file fixes a bug in the old system which prohibited your .mailrc
|
|
|
|
|
;; file from having lines like
|
|
|
|
|
;;
|
|
|
|
|
;; alias someone "John Doe <doe@quux.com>"
|
|
|
|
|
;;
|
|
|
|
|
;; That is, if you want an address to have embedded spaces, simply surround it
|
|
|
|
|
;; with double-quotes. This is necessary because the format of the .mailrc
|
|
|
|
|
;; file bogusly uses spaces as address delimiters. The following line defines
|
|
|
|
|
;; an alias which expands to three addresses:
|
|
|
|
|
;;
|
|
|
|
|
;; alias foobar addr-1 addr-2 "address three <addr-3>"
|
|
|
|
|
;;
|
|
|
|
|
;; (This is bogus because mail-delivery programs want commas, not spaces,
|
|
|
|
|
;; but that's what the file format is, so we have to live with it.)
|
|
|
|
|
;;
|
|
|
|
|
;; If you like, you can call the function define-mail-abbrev to define your
|
|
|
|
|
;; mail aliases instead of using a .mailrc file. When you call it in this
|
|
|
|
|
;; way, addresses are separated by commas.
|
|
|
|
|
;;
|
|
|
|
|
;; CAVEAT: This works on most Sun systems; I have been told that some versions
|
|
|
|
|
;; of /bin/mail do not understand double-quotes in the .mailrc file. So you
|
|
|
|
|
;; should make sure your version does before including verbose addresses like
|
|
|
|
|
;; this. One solution to this, if you are on a system whose /bin/mail doesn't
|
|
|
|
|
;; work that way, (and you still want to be able to /bin/mail to send mail in
|
|
|
|
|
;; addition to emacs) is to define minimal aliases (without full names) in
|
|
|
|
|
;; your .mailrc file, and use define-mail-abbrev to redefine them when sending
|
|
|
|
|
;; mail from emacs; this way, mail sent from /bin/mail will work, and mail
|
|
|
|
|
;; sent from emacs will be pretty.
|
|
|
|
|
;;
|
|
|
|
|
;; Aliases in the mailrc file may be nested. If you define aliases like
|
|
|
|
|
;; alias group1 fred ethel
|
|
|
|
|
;; alias group2 larry curly moe
|
|
|
|
|
;; alias everybody group1 group2
|
|
|
|
|
;; Then when you type "everybody" on the To: line, it will be expanded to
|
|
|
|
|
;; fred, ethyl, larry, curly, moe
|
|
|
|
|
;;
|
|
|
|
|
;; Aliases may also contain forward references; the alias of "everybody" can
|
|
|
|
|
;; precede the aliases of "group1" and "group2".
|
|
|
|
|
;;
|
|
|
|
|
;; This code also understands the "source" .mailrc command, for reading
|
|
|
|
|
;; aliases from some other file as well.
|
|
|
|
|
;;
|
|
|
|
|
;; Aliases may contain hyphens, as in "alias foo-bar foo@bar"; word-abbrevs
|
|
|
|
|
;; normally cannot contain hyphens, but this code works around that for the
|
|
|
|
|
;; specific case of mail-alias word-abbrevs.
|
|
|
|
|
;;
|
|
|
|
|
;; To read in the contents of another .mailrc-type file from emacs, use the
|
|
|
|
|
;; command Meta-X merge-mail-abbrevs. The rebuild-mail-abbrevs command is
|
|
|
|
|
;; similar, but will delete existing aliases first.
|
|
|
|
|
;;
|
|
|
|
|
;; If you would like your aliases to be expanded when you type M-> or ^N to
|
|
|
|
|
;; move out of the mail-header into the message body (instead of having to
|
|
|
|
|
;; type SPC at the end of the abbrev before moving away) then you can do
|
|
|
|
|
;;
|
|
|
|
|
;; (add-hook
|
2000-12-29 12:19:28 +00:00
|
|
|
|
;; 'mail-mode-hook
|
2000-08-16 21:05:37 +00:00
|
|
|
|
;; (lambda ()
|
2003-01-12 20:48:49 +00:00
|
|
|
|
;; (define-key mail-mode-map [remap next-line] 'mail-abbrev-next-line)
|
|
|
|
|
;; (define-key mail-mode-map [remap end-of-buffer] 'mail-abbrev-end-of-buffer)))
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
|
|
|
|
;; If you want multiple addresses separated by a string other than ", " then
|
|
|
|
|
;; you can set the variable mail-alias-separator-string to it. This has to
|
|
|
|
|
;; be a comma bracketed by whitespace if you want any kind of reasonable
|
|
|
|
|
;; behaviour.
|
|
|
|
|
;;
|
|
|
|
|
;; Thanks to Harald Hanche-Olsen, Michael Ernst, David Loeffler, and
|
|
|
|
|
;; Noah Friedman for suggestions and bug reports.
|
|
|
|
|
|
2000-12-29 12:19:28 +00:00
|
|
|
|
;; To use this package, do (add-hook 'mail-mode-hook 'mail-abbrevs-setup).
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2002-02-06 15:42:34 +00:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'sendmail))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(defgroup mail-abbrev nil
|
|
|
|
|
"Expand mail aliases as abbrevs, in certain mail headers."
|
|
|
|
|
:group 'abbrev-mode)
|
|
|
|
|
|
|
|
|
|
(defcustom mail-abbrevs-mode nil
|
|
|
|
|
"*Non-nil means expand mail aliases as abbrevs, in certain message headers."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'mail-abbrev
|
|
|
|
|
:require 'mailabbrev
|
2000-08-16 21:05:37 +00:00
|
|
|
|
:set (lambda (symbol value)
|
|
|
|
|
(setq mail-abbrevs-mode value)
|
|
|
|
|
(if value (mail-abbrevs-enable) (mail-abbrevs-disable)))
|
1998-04-20 03:35:05 +00:00
|
|
|
|
:initialize 'custom-initialize-default
|
|
|
|
|
:version "20.3")
|
1997-10-21 02:54:50 +00:00
|
|
|
|
|
|
|
|
|
(defcustom mail-abbrevs-only nil
|
|
|
|
|
"*Non-nil means only mail abbrevs should expand automatically.
|
|
|
|
|
Other abbrevs expand only when you explicitly use `expand-abbrev'."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'mail-abbrev)
|
|
|
|
|
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; originally defined in sendmail.el - used to be an alist, now is a table.
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defvar mail-abbrevs nil
|
1992-03-24 04:22:48 +00:00
|
|
|
|
"Word-abbrev table of mail address aliases.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
If this is nil, it means the aliases have not yet been initialized and
|
|
|
|
|
should be read from the .mailrc file. (This is distinct from there being
|
|
|
|
|
no aliases, which is represented by this being a table with no entries.)")
|
|
|
|
|
|
1996-03-09 08:48:56 +00:00
|
|
|
|
(defvar mail-abbrev-modtime nil
|
|
|
|
|
"The modification time of your mail alias file when it was last examined.")
|
|
|
|
|
|
|
|
|
|
(defun mail-abbrevs-sync-aliases ()
|
2003-08-29 16:12:38 +00:00
|
|
|
|
(when mail-personal-alias-file
|
|
|
|
|
(if (file-exists-p mail-personal-alias-file)
|
|
|
|
|
(let ((modtime (nth 5 (file-attributes mail-personal-alias-file))))
|
|
|
|
|
(if (not (equal mail-abbrev-modtime modtime))
|
|
|
|
|
(progn
|
|
|
|
|
(setq mail-abbrev-modtime modtime)
|
|
|
|
|
(build-mail-abbrevs)))))))
|
1996-03-09 08:48:56 +00:00
|
|
|
|
|
1991-12-21 09:14:03 +00:00
|
|
|
|
;;;###autoload
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun mail-abbrevs-setup ()
|
1996-03-05 22:04:03 +00:00
|
|
|
|
"Initialize use of the `mailabbrev' package."
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (and (not (vectorp mail-abbrevs))
|
1995-01-03 23:44:25 +00:00
|
|
|
|
(file-exists-p mail-personal-alias-file))
|
1996-03-09 08:48:56 +00:00
|
|
|
|
(progn
|
1996-05-26 23:12:01 +00:00
|
|
|
|
(setq mail-abbrev-modtime
|
1996-03-09 08:48:56 +00:00
|
|
|
|
(nth 5 (file-attributes mail-personal-alias-file)))
|
|
|
|
|
(build-mail-abbrevs)))
|
|
|
|
|
(mail-abbrevs-sync-aliases)
|
1995-03-18 07:14:50 +00:00
|
|
|
|
(add-hook 'pre-abbrev-expand-hook 'sendmail-pre-abbrev-expand-hook
|
|
|
|
|
nil t)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(abbrev-mode 1))
|
|
|
|
|
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(defun mail-abbrevs-enable ()
|
2000-12-29 12:19:28 +00:00
|
|
|
|
(add-hook 'mail-mode-hook 'mail-abbrevs-setup))
|
1997-10-21 02:54:50 +00:00
|
|
|
|
|
|
|
|
|
(defun mail-abbrevs-disable ()
|
|
|
|
|
"Turn off use of the `mailabbrev' package."
|
2000-12-29 12:19:28 +00:00
|
|
|
|
(remove-hook 'mail-mode-hook 'mail-abbrevs-setup)
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(abbrev-mode (if (default-value 'abbrev-mode) 1 -1)))
|
|
|
|
|
|
1992-03-24 04:22:48 +00:00
|
|
|
|
;;;###autoload
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun build-mail-abbrevs (&optional file recursivep)
|
1995-01-03 23:44:25 +00:00
|
|
|
|
"Read mail aliases from personal mail alias file and set `mail-abbrevs'.
|
|
|
|
|
By default this is the file specified by `mail-personal-alias-file'."
|
|
|
|
|
(setq file (expand-file-name (or file mail-personal-alias-file)))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (vectorp mail-abbrevs)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
nil
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(setq mail-abbrevs nil)
|
|
|
|
|
(define-abbrev-table 'mail-abbrevs '()))
|
1992-04-05 23:25:04 +00:00
|
|
|
|
(message "Parsing %s..." file)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(let ((buffer nil)
|
|
|
|
|
(obuf (current-buffer)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
1997-11-07 21:55:40 +00:00
|
|
|
|
(setq buffer (generate-new-buffer " mailrc"))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
(buffer-disable-undo buffer)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(set-buffer buffer)
|
|
|
|
|
(cond ((get-file-buffer file)
|
|
|
|
|
(insert (save-excursion
|
|
|
|
|
(set-buffer (get-file-buffer file))
|
|
|
|
|
(buffer-substring (point-min) (point-max)))))
|
|
|
|
|
((not (file-exists-p file)))
|
|
|
|
|
(t (insert-file-contents file)))
|
|
|
|
|
;; Don't lose if no final newline.
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(or (eq (preceding-char) ?\n) (newline))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
;; Delete comments from the file
|
|
|
|
|
(while (search-forward "# " nil t)
|
|
|
|
|
(let ((p (- (point) 2)))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(delete-region p (point))))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
;; handle "\\\n" continuation lines
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(if (= (preceding-char) ?\\)
|
|
|
|
|
(progn (delete-char -1) (delete-char 1) (insert ?\ ))
|
|
|
|
|
(forward-char 1)))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (re-search-forward
|
1992-08-02 03:36:38 +00:00
|
|
|
|
"^\\(a\\(lias\\)?\\|g\\(roup\\)?\\|source\\)[ \t]+" nil t)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if (looking-at "source[ \t]+\\([^ \t\n]+\\)")
|
|
|
|
|
(progn
|
|
|
|
|
(end-of-line)
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(build-mail-abbrevs
|
1993-07-01 20:25:42 +00:00
|
|
|
|
(substitute-in-file-name
|
1994-06-17 16:03:59 +00:00
|
|
|
|
(buffer-substring (match-beginning 1) (match-end 1)))
|
|
|
|
|
t))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(re-search-forward "[ \t]+\\([^ \t\n]+\\)")
|
|
|
|
|
(let* ((name (buffer-substring
|
|
|
|
|
(match-beginning 1) (match-end 1)))
|
|
|
|
|
(start (progn (skip-chars-forward " \t") (point))))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
; (message "** %s \"%s\"" name (buffer-substring start (point)))(sit-for 1)
|
1993-06-15 20:50:11 +00:00
|
|
|
|
(define-mail-abbrev
|
1991-12-17 03:37:43 +00:00
|
|
|
|
name
|
1993-06-15 20:50:11 +00:00
|
|
|
|
(buffer-substring start (point))
|
|
|
|
|
t))))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; Resolve forward references in .mailrc file.
|
|
|
|
|
;; This would happen automatically before the first abbrev was
|
|
|
|
|
;; expanded, but why not do it now.
|
|
|
|
|
(or recursivep (mail-resolve-all-aliases))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
mail-abbrevs)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(if buffer (kill-buffer buffer))
|
|
|
|
|
(set-buffer obuf)))
|
1992-04-05 23:25:04 +00:00
|
|
|
|
(message "Parsing %s... done" file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1992-05-03 21:16:09 +00:00
|
|
|
|
(defvar mail-alias-separator-string ", "
|
1991-12-17 03:37:43 +00:00
|
|
|
|
"*A string inserted between addresses in multi-address mail aliases.
|
1996-05-26 23:12:01 +00:00
|
|
|
|
This has to contain a comma, so \", \" is a reasonable value. You might
|
1991-12-17 03:37:43 +00:00
|
|
|
|
also want something like \",\\n \" to get each address on its own line.")
|
|
|
|
|
|
1993-06-15 20:50:11 +00:00
|
|
|
|
;; define-mail-abbrev sets this flag, which causes mail-resolve-all-aliases
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; to be called before expanding abbrevs if it's necessary.
|
|
|
|
|
(defvar mail-abbrev-aliases-need-to-be-resolved t)
|
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
;; originally defined in mailalias.el ; build-mail-abbrevs calls this with
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; stuff parsed from the .mailrc file.
|
|
|
|
|
;;
|
1991-12-21 09:14:03 +00:00
|
|
|
|
;;;###autoload
|
1993-06-15 20:50:11 +00:00
|
|
|
|
(defun define-mail-abbrev (name definition &optional from-mailrc-file)
|
1995-03-18 07:14:50 +00:00
|
|
|
|
"Define NAME as a mail alias abbrev that translates to DEFINITION.
|
1992-05-03 21:16:09 +00:00
|
|
|
|
If DEFINITION contains multiple addresses, separate them with commas."
|
1992-10-18 22:20:07 +00:00
|
|
|
|
;; When this is called from build-mail-abbrevs, the third argument is
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; true, and we do some evil space->comma hacking like /bin/mail does.
|
|
|
|
|
(interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
|
|
|
|
|
;; Read the defaults first, if we have not done so.
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (vectorp mail-abbrevs)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
nil
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(setq mail-abbrevs nil)
|
|
|
|
|
(define-abbrev-table 'mail-abbrevs '())
|
1995-01-03 23:44:25 +00:00
|
|
|
|
(if (file-exists-p mail-personal-alias-file)
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(build-mail-abbrevs)))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; strip garbage from front and end
|
|
|
|
|
(if (string-match "\\`[ \t\n,]+" definition)
|
|
|
|
|
(setq definition (substring definition (match-end 0))))
|
|
|
|
|
(if (string-match "[ \t\n,]+\\'" definition)
|
|
|
|
|
(setq definition (substring definition 0 (match-beginning 0))))
|
1994-07-12 02:16:57 +00:00
|
|
|
|
(let* ((result '())
|
|
|
|
|
(L (length definition))
|
|
|
|
|
(start (if (> L 0) 0))
|
|
|
|
|
end)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(while start
|
|
|
|
|
;; If we're reading from the mailrc file, then addresses are delimited
|
|
|
|
|
;; by spaces, and addresses with embedded spaces must be surrounded by
|
1992-05-03 21:16:09 +00:00
|
|
|
|
;; double-quotes. Otherwise, addresses are separated by commas.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(if from-mailrc-file
|
|
|
|
|
(if (eq ?\" (aref definition start))
|
|
|
|
|
(setq start (1+ start)
|
|
|
|
|
end (string-match "\"[ \t,]*" definition start))
|
1994-07-12 02:16:57 +00:00
|
|
|
|
(setq end (string-match "[ \t,]+" definition start)))
|
|
|
|
|
(setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
|
2005-01-04 14:59:47 +00:00
|
|
|
|
(let ((tem (substring definition start end)))
|
|
|
|
|
;; Advance the loop past this address.
|
|
|
|
|
(setq start (and end
|
|
|
|
|
(/= (match-end 0) L)
|
|
|
|
|
(match-end 0)))
|
|
|
|
|
;; If the full name contains a problem character, quote it.
|
|
|
|
|
(when (string-match "\\(.+?\\)[ \t]*\\(<.*>\\)" tem)
|
|
|
|
|
(if (string-match "[^- !#$%&'*+/0-9=?A-Za-z^_`{|}~]"
|
|
|
|
|
(match-string 1 tem))
|
|
|
|
|
(setq tem (replace-regexp-in-string
|
|
|
|
|
"\\(.+?\\)[ \t]*\\(<.*>\\)" "\"\\1\" \\2"
|
|
|
|
|
tem))))
|
|
|
|
|
(push tem result)))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(setq definition (mapconcat (function identity)
|
|
|
|
|
(nreverse result)
|
1992-05-03 21:16:09 +00:00
|
|
|
|
mail-alias-separator-string)))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(setq mail-abbrev-aliases-need-to-be-resolved t)
|
|
|
|
|
(setq name (downcase name))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
;; use an abbrev table instead of an alist for mail-abbrevs.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(let ((abbrevs-changed abbrevs-changed)) ; protect this from being changed.
|
2002-02-13 15:59:53 +00:00
|
|
|
|
(define-abbrev mail-abbrevs name definition 'mail-abbrev-expand-hook 0 t)))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun mail-resolve-all-aliases ()
|
|
|
|
|
"Resolve all forward references in the mail aliases table."
|
|
|
|
|
(if mail-abbrev-aliases-need-to-be-resolved
|
|
|
|
|
(progn
|
|
|
|
|
;; (message "Resolving mail aliases...")
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (vectorp mail-abbrevs)
|
|
|
|
|
(mapatoms (function mail-resolve-all-aliases-1) mail-abbrevs))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(setq mail-abbrev-aliases-need-to-be-resolved nil)
|
|
|
|
|
;; (message "Resolving mail aliases... done.")
|
|
|
|
|
)))
|
|
|
|
|
|
1992-06-15 21:06:57 +00:00
|
|
|
|
(defun mail-resolve-all-aliases-1 (sym &optional so-far)
|
|
|
|
|
(if (memq sym so-far)
|
|
|
|
|
(error "mail alias loop detected: %s"
|
|
|
|
|
(mapconcat 'symbol-name (cons sym so-far) " <- ")))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(let ((definition (and (boundp sym) (symbol-value sym))))
|
|
|
|
|
(if definition
|
|
|
|
|
(let ((result '())
|
|
|
|
|
(start 0))
|
|
|
|
|
(while start
|
|
|
|
|
(let ((end (string-match "[ \t\n]*,[, \t\n]*" definition start)))
|
|
|
|
|
(setq result (cons (substring definition start end) result)
|
|
|
|
|
start (and end (match-end 0)))))
|
|
|
|
|
(setq definition
|
|
|
|
|
(mapconcat (function (lambda (x)
|
|
|
|
|
(or (mail-resolve-all-aliases-1
|
1995-06-30 05:54:07 +00:00
|
|
|
|
(intern-soft (downcase x) mail-abbrevs)
|
1992-06-15 21:06:57 +00:00
|
|
|
|
(cons sym so-far))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
x)))
|
|
|
|
|
(nreverse result)
|
1992-05-03 21:16:09 +00:00
|
|
|
|
mail-alias-separator-string))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(set sym definition))))
|
|
|
|
|
(symbol-value sym))
|
|
|
|
|
|
|
|
|
|
|
1992-05-03 21:16:09 +00:00
|
|
|
|
(defun mail-abbrev-expand-hook ()
|
1995-03-18 07:14:50 +00:00
|
|
|
|
"For use as the fourth arg to `define-abbrev'.
|
|
|
|
|
After expanding a mail-abbrev, if Auto Fill mode is on and we're past the
|
|
|
|
|
fill-column, break the line at the previous comma, and indent the next line."
|
1996-05-26 23:12:01 +00:00
|
|
|
|
;; Disable abbrev mode to avoid recursion in indent-relative expanding
|
|
|
|
|
;; part of the abbrev expansion as an abbrev itself.
|
|
|
|
|
(let ((abbrev-mode nil))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((p (point))
|
|
|
|
|
bol comma fp)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq bol (point))
|
|
|
|
|
(goto-char p)
|
|
|
|
|
(while (and auto-fill-function
|
|
|
|
|
(>= (current-column) fill-column)
|
|
|
|
|
(search-backward "," bol t))
|
|
|
|
|
(setq comma (point))
|
|
|
|
|
(forward-char 1) ; Now we are just past the comma.
|
|
|
|
|
(insert "\n")
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(setq p (point))
|
|
|
|
|
(indent-relative)
|
|
|
|
|
(setq fp (buffer-substring p (point)))
|
|
|
|
|
;; Go to the end of the new line.
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(if (> (current-column) fill-column)
|
|
|
|
|
;; It's still too long; do normal auto-fill.
|
|
|
|
|
(let ((fill-prefix (or fp "\t")))
|
|
|
|
|
(do-auto-fill)))
|
|
|
|
|
;; Resume the search.
|
|
|
|
|
(goto-char comma)
|
|
|
|
|
)))))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
|
|
|
|
;;; Syntax tables and abbrev-expansion
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1996-05-26 23:12:01 +00:00
|
|
|
|
(defvar mail-abbrev-mode-regexp
|
1994-01-11 05:38:36 +00:00
|
|
|
|
"^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):"
|
1995-03-18 07:14:50 +00:00
|
|
|
|
"*Regexp to select mail-headers in which mail abbrevs should be expanded.
|
1995-02-17 18:31:47 +00:00
|
|
|
|
This string will be handed to `looking-at' with point at the beginning
|
1991-12-17 03:37:43 +00:00
|
|
|
|
of the current line; if it matches, abbrev mode will be turned on, otherwise
|
|
|
|
|
it will be turned off. (You don't need to worry about continuation lines.)
|
|
|
|
|
This should be set to match those mail fields in which you want abbreviations
|
|
|
|
|
turned on.")
|
|
|
|
|
|
2002-02-06 15:42:34 +00:00
|
|
|
|
(defvar mail-abbrev-syntax-table nil
|
1995-10-20 20:57:42 +00:00
|
|
|
|
"The syntax-table used for abbrev-expansion purposes.
|
|
|
|
|
This is not actually made the current syntax table of the buffer, but
|
|
|
|
|
simply controls the set of characters which may be a part of the name
|
2002-02-06 15:42:34 +00:00
|
|
|
|
of a mail alias. The value is set up, buffer-local, when first needed.")
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(defun mail-abbrev-make-syntax-table ()
|
|
|
|
|
(make-local-variable 'mail-abbrev-syntax-table)
|
|
|
|
|
(unless mail-abbrev-syntax-table
|
2002-04-04 20:50:15 +00:00
|
|
|
|
(let ((tab (copy-syntax-table (syntax-table)))
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(_ (aref (standard-syntax-table) ?_))
|
|
|
|
|
(w (aref (standard-syntax-table) ?w)))
|
|
|
|
|
(map-char-table
|
|
|
|
|
(function (lambda (key value)
|
2002-07-13 21:40:05 +00:00
|
|
|
|
(if (null value)
|
|
|
|
|
;; Fetch the inherited value
|
|
|
|
|
(setq value (aref tab key)))
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(if (equal value _)
|
|
|
|
|
(set-char-table-range tab key w))))
|
|
|
|
|
tab)
|
|
|
|
|
(modify-syntax-entry ?@ "w" tab)
|
2002-09-21 20:11:08 +00:00
|
|
|
|
(modify-syntax-entry ?% "w" tab)
|
|
|
|
|
(modify-syntax-entry ?! "w" tab)
|
|
|
|
|
(modify-syntax-entry ?. "w" tab)
|
|
|
|
|
(modify-syntax-entry ?_ "w" tab)
|
|
|
|
|
(modify-syntax-entry ?- "w" tab)
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(setq mail-abbrev-syntax-table tab))))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
|
|
|
|
(defun mail-abbrev-in-expansion-header-p ()
|
|
|
|
|
"Whether point is in a mail-address header field."
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(and ;;
|
|
|
|
|
;; we are on an appropriate header line...
|
|
|
|
|
(save-excursion
|
2001-10-05 09:34:27 +00:00
|
|
|
|
(unless (eobp) (forward-char 1))
|
|
|
|
|
(re-search-backward "^[^ \t]" nil 'move)
|
1992-03-24 04:22:48 +00:00
|
|
|
|
;; are we at the front of an appropriate header line?
|
|
|
|
|
(looking-at mail-abbrev-mode-regexp))
|
|
|
|
|
;;
|
1998-04-30 06:26:19 +00:00
|
|
|
|
;; ...and are we in the headers?
|
2002-02-13 15:59:53 +00:00
|
|
|
|
(< (point)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(rfc822-goto-eoh)
|
|
|
|
|
(point)))))))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
1992-05-03 21:16:09 +00:00
|
|
|
|
(defun sendmail-pre-abbrev-expand-hook ()
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(and (and mail-abbrevs (not (eq mail-abbrevs t)))
|
1992-09-15 19:38:02 +00:00
|
|
|
|
(if (mail-abbrev-in-expansion-header-p)
|
2002-02-06 15:42:34 +00:00
|
|
|
|
|
|
|
|
|
;; We are in a To: (or CC:, or whatever) header, and
|
|
|
|
|
;; should use word-abbrevs to expand mail aliases.
|
|
|
|
|
(let ((local-abbrev-table mail-abbrevs)
|
|
|
|
|
(old-syntax-table (syntax-table)))
|
1992-09-15 19:38:02 +00:00
|
|
|
|
|
|
|
|
|
;; Before anything else, resolve aliases if they need it.
|
|
|
|
|
(and mail-abbrev-aliases-need-to-be-resolved
|
|
|
|
|
(mail-resolve-all-aliases))
|
|
|
|
|
|
|
|
|
|
;; Now proceed with the abbrev section.
|
2002-02-06 15:42:34 +00:00
|
|
|
|
;; - We already installed mail-abbrevs as the abbrev table.
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;; - Then install the mail-abbrev-syntax-table, which
|
|
|
|
|
;; temporarily marks all of the
|
|
|
|
|
;; non-alphanumeric-atom-characters (the "_"
|
|
|
|
|
;; syntax ones) as being normal word-syntax. We do this
|
|
|
|
|
;; because the C code for expand-abbrev only works on words,
|
|
|
|
|
;; and we want these characters to be considered words for
|
|
|
|
|
;; the purpose of abbrev expansion.
|
|
|
|
|
;; - Then we call expand-abbrev again, recursively, to do
|
|
|
|
|
;; the abbrev expansion with the above syntax table.
|
2002-02-06 15:42:34 +00:00
|
|
|
|
;; - Restore the previous syntax table.
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;; - Then we do a trick which tells the expand-abbrev frame
|
|
|
|
|
;; which invoked us to not continue (and thus not
|
|
|
|
|
;; expand twice.) This means that any abbrev expansion
|
|
|
|
|
;; will happen as a result of this function's call to
|
|
|
|
|
;; expand-abbrev, and not as a result of the call to
|
|
|
|
|
;; expand-abbrev which invoked *us*.
|
|
|
|
|
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(mail-abbrev-make-syntax-table)
|
1992-09-15 19:38:02 +00:00
|
|
|
|
|
|
|
|
|
;; If the character just typed was non-alpha-symbol-syntax,
|
|
|
|
|
;; then don't expand the abbrev now (that is, don't expand
|
|
|
|
|
;; when the user types -.) Check the character's syntax in
|
2002-02-06 15:42:34 +00:00
|
|
|
|
;; the usual syntax table.
|
1992-09-15 19:38:02 +00:00
|
|
|
|
|
1993-06-11 22:22:15 +00:00
|
|
|
|
(or (and (integerp last-command-char)
|
2005-01-04 14:59:47 +00:00
|
|
|
|
(or (eq (char-syntax last-command-char) ?_)
|
|
|
|
|
;; Don't expand on @.
|
|
|
|
|
(memq last-command-char '(?@ ?. ?% ?! ?_ ?-))))
|
1992-09-15 19:38:02 +00:00
|
|
|
|
(let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
|
|
|
|
|
;; Use this table so that abbrevs can have hyphens in them.
|
|
|
|
|
(set-syntax-table mail-abbrev-syntax-table)
|
2002-02-06 15:42:34 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(expand-abbrev)
|
|
|
|
|
;; Now set it back to what it was before.
|
|
|
|
|
(set-syntax-table old-syntax-table))))
|
1995-04-20 21:27:14 +00:00
|
|
|
|
(setq abbrev-start-location (point-max) ; This is the trick.
|
1992-09-15 19:38:02 +00:00
|
|
|
|
abbrev-start-location-buffer (current-buffer)))
|
|
|
|
|
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(if (or (not mail-abbrevs-only)
|
|
|
|
|
(eq this-command 'expand-abbrev))
|
2002-02-06 15:42:34 +00:00
|
|
|
|
;; We're not in a mail header where mail aliases should
|
|
|
|
|
;; be expanded, then use the normal mail-mode abbrev table
|
|
|
|
|
;; (if any) and the normal mail-mode syntax table.
|
|
|
|
|
nil
|
1997-10-21 02:54:50 +00:00
|
|
|
|
;; This is not a mail abbrev, and we should not expand it.
|
|
|
|
|
;; This kludge stops expand-abbrev from doing anything.
|
|
|
|
|
(setq abbrev-start-location (point-max)
|
|
|
|
|
abbrev-start-location-buffer (current-buffer))))
|
1992-09-15 19:38:02 +00:00
|
|
|
|
))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
|
|
|
|
;;; utilities
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun merge-mail-abbrevs (file)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
"Merge mail aliases from the given file with existing ones."
|
|
|
|
|
(interactive (list
|
|
|
|
|
(let ((insert-default-directory t)
|
|
|
|
|
(default-directory (expand-file-name "~/"))
|
1995-01-03 23:44:25 +00:00
|
|
|
|
(def mail-personal-alias-file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(read-file-name
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
|
(format "Read additional aliases from file (default %s): "
|
1991-12-17 03:37:43 +00:00
|
|
|
|
def)
|
|
|
|
|
default-directory
|
|
|
|
|
(expand-file-name def default-directory)
|
|
|
|
|
t))))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(build-mail-abbrevs file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1995-08-25 21:34:09 +00:00
|
|
|
|
(defun rebuild-mail-abbrevs (&optional file)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
"Rebuild all the mail aliases from the given file."
|
|
|
|
|
(interactive (list
|
|
|
|
|
(let ((insert-default-directory t)
|
|
|
|
|
(default-directory (expand-file-name "~/"))
|
1995-01-03 23:44:25 +00:00
|
|
|
|
(def mail-personal-alias-file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(read-file-name
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
|
(format "Read mail aliases from file (default %s): " def)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
default-directory
|
|
|
|
|
(expand-file-name def default-directory)
|
|
|
|
|
t))))
|
1995-08-25 21:34:09 +00:00
|
|
|
|
(if (null file)
|
|
|
|
|
(setq file buffer-file-name))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(setq mail-abbrevs nil)
|
|
|
|
|
(build-mail-abbrevs file))
|
1992-03-16 20:39:07 +00:00
|
|
|
|
|
2000-05-03 19:25:07 +00:00
|
|
|
|
(defun mail-abbrev-insert-alias (&optional alias)
|
1992-03-24 04:22:48 +00:00
|
|
|
|
"Prompt for and insert a mail alias."
|
1992-08-02 03:36:38 +00:00
|
|
|
|
(interactive (progn
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
|
|
|
|
|
(list (completing-read "Expand alias: " mail-abbrevs nil t))))
|
|
|
|
|
(if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
|
1995-09-04 20:26:58 +00:00
|
|
|
|
(insert (or (and alias (symbol-value (intern-soft alias mail-abbrevs))) ""))
|
|
|
|
|
(mail-abbrev-expand-hook))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
|
2000-05-03 19:25:07 +00:00
|
|
|
|
(defun mail-abbrev-complete-alias ()
|
|
|
|
|
"Perform completion on alias preceding point."
|
|
|
|
|
;; Based on lisp.el:lisp-complete-symbol
|
|
|
|
|
(interactive)
|
2002-04-03 15:33:17 +00:00
|
|
|
|
(mail-abbrev-make-syntax-table)
|
2000-05-03 19:25:07 +00:00
|
|
|
|
(let* ((end (point))
|
|
|
|
|
(syntax-table (syntax-table))
|
|
|
|
|
(beg (unwind-protect
|
|
|
|
|
(save-excursion
|
|
|
|
|
(set-syntax-table mail-abbrev-syntax-table)
|
|
|
|
|
(backward-word 1)
|
|
|
|
|
(point))
|
|
|
|
|
(set-syntax-table syntax-table)))
|
|
|
|
|
(alias (buffer-substring beg end))
|
|
|
|
|
(completion (try-completion alias mail-abbrevs)))
|
|
|
|
|
(cond ((eq completion t)
|
|
|
|
|
(message "%s" alias)) ; confirm
|
|
|
|
|
((null completion)
|
|
|
|
|
(error "[Can't complete \"%s\"]" alias)) ; (message ...) (ding)
|
|
|
|
|
((not (string= completion alias))
|
|
|
|
|
(delete-region beg end)
|
|
|
|
|
(insert completion))
|
|
|
|
|
(t (with-output-to-temp-buffer "*Completions*"
|
|
|
|
|
(display-completion-list
|
|
|
|
|
(prog2
|
|
|
|
|
(message "Making completion list...")
|
|
|
|
|
(all-completions alias mail-abbrevs)
|
2005-10-16 09:31:48 +00:00
|
|
|
|
(message "Making completion list...done"))
|
|
|
|
|
alias))))))
|
2000-05-03 19:25:07 +00:00
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun mail-abbrev-next-line (&optional arg)
|
|
|
|
|
"Expand any mail abbrev, then move cursor vertically down ARG lines.
|
|
|
|
|
If there is no character in the target line exactly under the current column,
|
|
|
|
|
the cursor is positioned after the character in that line which spans this
|
|
|
|
|
column, or at the end of the line if it is not long enough.
|
|
|
|
|
If there is no line in the buffer after this one,
|
|
|
|
|
a newline character is inserted to create a line
|
|
|
|
|
and the cursor moves to that line.
|
|
|
|
|
|
|
|
|
|
The command \\[set-goal-column] can be used to create
|
|
|
|
|
a semipermanent goal column to which this command always moves.
|
|
|
|
|
Then it does not try to move vertically. This goal column is stored
|
|
|
|
|
in `goal-column', which is nil when there is none.
|
|
|
|
|
|
|
|
|
|
If you are thinking of using this in a Lisp program, consider
|
|
|
|
|
using `forward-line' instead. It is usually easier to use
|
|
|
|
|
and more reliable (no dependence on goal column, etc.)."
|
1992-03-24 04:22:48 +00:00
|
|
|
|
(interactive "p")
|
1992-06-15 21:06:57 +00:00
|
|
|
|
(if (looking-at "[ \t]*\n") (expand-abbrev))
|
|
|
|
|
(setq this-command 'next-line)
|
1992-03-24 04:22:48 +00:00
|
|
|
|
(next-line arg))
|
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun mail-abbrev-end-of-buffer (&optional arg)
|
|
|
|
|
"Expand any mail abbrev, then move point to end of buffer.
|
|
|
|
|
Leave mark at previous position.
|
|
|
|
|
With arg N, put point N/10 of the way from the true end.
|
|
|
|
|
|
|
|
|
|
Don't use this command in Lisp programs!
|
|
|
|
|
\(goto-char (point-max)) is faster and avoids clobbering the mark."
|
1993-07-08 21:14:43 +00:00
|
|
|
|
(interactive "P")
|
1992-06-15 21:06:57 +00:00
|
|
|
|
(if (looking-at "[ \t]*\n") (expand-abbrev))
|
|
|
|
|
(setq this-command 'end-of-buffer)
|
2005-01-04 14:59:47 +00:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(end-of-buffer arg)))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
2002-02-09 09:46:08 +00:00
|
|
|
|
(eval-after-load "sendmail"
|
|
|
|
|
'(progn
|
|
|
|
|
(define-key mail-mode-map "\C-c\C-a" 'mail-abbrev-insert-alias)
|
|
|
|
|
(define-key mail-mode-map "\e\t" ; like lisp-complete-symbol
|
|
|
|
|
'mail-abbrev-complete-alias)))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
;;(define-key mail-mode-map "\C-n" 'mail-abbrev-next-line)
|
|
|
|
|
;;(define-key mail-mode-map "\M->" 'mail-abbrev-end-of-buffer)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1993-03-29 08:09:35 +00:00
|
|
|
|
(provide 'mailabbrev)
|
1996-01-14 07:34:30 +00:00
|
|
|
|
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(if mail-abbrevs-mode
|
|
|
|
|
(mail-abbrevs-enable))
|
|
|
|
|
|
2003-09-01 15:45:59 +00:00
|
|
|
|
;;; arch-tag: 5aa2d901-73f8-4ad7-b73c-4802282ad2ff
|
2001-07-15 16:15:35 +00:00
|
|
|
|
;;; mailabbrev.el ends here
|