diff options
| author | Roland McGrath | 1992-09-15 19:38:02 +0000 |
|---|---|---|
| committer | Roland McGrath | 1992-09-15 19:38:02 +0000 |
| commit | 275da7879142a80cf3de5b81d494b0d69ec6b831 (patch) | |
| tree | 09946b79257be37361e7961b7428456402a16855 | |
| parent | 8e0e25bb904e87c50d7173383e80af9e741ab808 (diff) | |
| download | emacs-275da7879142a80cf3de5b81d494b0d69ec6b831.tar.gz emacs-275da7879142a80cf3de5b81d494b0d69ec6b831.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/mail/mailabbrev.el | 133 |
1 files changed, 76 insertions, 57 deletions
diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el index 849025c0d35..efc4996fe32 100644 --- a/lisp/mail/mailabbrev.el +++ b/lisp/mail/mailabbrev.el | |||
| @@ -1,8 +1,13 @@ | |||
| 1 | ;;; Abbrev-expansion of mail aliases. | 1 | ;;; mailabbrev.el --- abbrev-expansion of mail aliases. |
| 2 | |||
| 2 | ;;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc. | 3 | ;;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc. |
| 3 | ;;; Created: 19 oct 90, Jamie Zawinski <jwz@lucid.com> | 4 | |
| 4 | ;;; Modified: 5 apr 92, Roland McGrath <roland@gnu.ai.mit.edu> | 5 | ;; Author: Jamie Zawinski <jwz@lucid.com> |
| 5 | ;;; Last change 27-aug-92. jwz | 6 | ;; Maintainer: Jamie Zawinski <jwz@lucid.com> |
| 7 | ;; Created: 19 Oct 90 | ||
| 8 | ;; Keywords: mail | ||
| 9 | |||
| 10 | ;;; ??? We must get papers for this or delete it. | ||
| 6 | 11 | ||
| 7 | ;;; This file is part of GNU Emacs. | 12 | ;;; This file is part of GNU Emacs. |
| 8 | 13 | ||
| @@ -20,6 +25,8 @@ | |||
| 20 | ;;; along with GNU Emacs; see the file COPYING. If not, write to | 25 | ;;; along with GNU Emacs; see the file COPYING. If not, write to |
| 21 | ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | 27 | ||
| 28 | ;;; Commentary: | ||
| 29 | |||
| 23 | ;;; This file ensures that, when the point is in a To:, CC:, BCC:, or From: | 30 | ;;; This file ensures that, when the point is in a To:, CC:, BCC:, or From: |
| 24 | ;;; field, word-abbrevs are defined for each of your mail aliases. These | 31 | ;;; field, word-abbrevs are defined for each of your mail aliases. These |
| 25 | ;;; aliases will be defined from your .mailrc file (or the file specified by | 32 | ;;; aliases will be defined from your .mailrc file (or the file specified by |
| @@ -139,6 +146,8 @@ | |||
| 139 | ;;; - Remove the autoload of build-mail-aliases from the file sendmail.el; | 146 | ;;; - Remove the autoload of build-mail-aliases from the file sendmail.el; |
| 140 | ;;; - Add an autoload of define-mail-alias to loaddefs.el. | 147 | ;;; - Add an autoload of define-mail-alias to loaddefs.el. |
| 141 | 148 | ||
| 149 | ;;; Code: | ||
| 150 | |||
| 142 | (require 'sendmail) | 151 | (require 'sendmail) |
| 143 | 152 | ||
| 144 | (defvar mail-abbrev-mailrc-file nil | 153 | (defvar mail-abbrev-mailrc-file nil |
| @@ -434,55 +443,66 @@ characters which may be a part of the name of a mail-alias.") | |||
| 434 | (defvar mail-mode-abbrev-table) ; quiet the compiler | 443 | (defvar mail-mode-abbrev-table) ; quiet the compiler |
| 435 | 444 | ||
| 436 | (defun sendmail-pre-abbrev-expand-hook () | 445 | (defun sendmail-pre-abbrev-expand-hook () |
| 437 | (if mail-abbrev-aliases-need-to-be-resolved | 446 | (and (and mail-aliases (not (eq mail-aliases t))) |
| 438 | (mail-resolve-all-aliases)) | 447 | (if (mail-abbrev-in-expansion-header-p) |
| 439 | (if (and mail-aliases (not (eq mail-aliases t))) | 448 | (progn |
| 440 | (if (not (mail-abbrev-in-expansion-header-p)) | 449 | ;; |
| 441 | ;; | 450 | ;; We are in a To: (or CC:, or whatever) header, and |
| 442 | ;; If we're not in a mail header in which mail aliases should | 451 | ;; should use word-abbrevs to expand mail aliases. |
| 443 | ;; be expanded, then use the normal mail-mode abbrev table (if any) | 452 | |
| 444 | ;; and the normal mail-mode syntax table. | 453 | ;; Before anything else, resolve aliases if they need it. |
| 445 | ;; | 454 | (and mail-abbrev-aliases-need-to-be-resolved |
| 446 | (progn | 455 | (mail-resolve-all-aliases)) |
| 447 | (setq local-abbrev-table (and (boundp 'mail-mode-abbrev-table) | 456 | |
| 448 | mail-mode-abbrev-table)) | 457 | ;; Now proceed with the abbrev section. |
| 449 | (set-syntax-table mail-mode-syntax-table)) | 458 | ;; - First, install the mail-aliases as the word-abbrev table. |
| 450 | ;; | 459 | ;; - Then install the mail-abbrev-syntax-table, which |
| 451 | ;; Otherwise, we are in a To: (or CC:, or whatever) header, and | 460 | ;; temporarily marks all of the |
| 452 | ;; should use word-abbrevs to expand mail aliases. | 461 | ;; non-alphanumeric-atom-characters (the "_" |
| 453 | ;; - First, install the mail-aliases as the word-abbrev table. | 462 | ;; syntax ones) as being normal word-syntax. We do this |
| 454 | ;; - Then install the mail-abbrev-syntax-table, which temporarily | 463 | ;; because the C code for expand-abbrev only works on words, |
| 455 | ;; marks all of the non-alphanumeric-atom-characters (the "_" | 464 | ;; and we want these characters to be considered words for |
| 456 | ;; syntax ones) as being normal word-syntax. We do this because | 465 | ;; the purpose of abbrev expansion. |
| 457 | ;; the C code for expand-abbrev only works on words, and we want | 466 | ;; - Then we call expand-abbrev again, recursively, to do |
| 458 | ;; these characters to be considered words for the purpose of | 467 | ;; the abbrev expansion with the above syntax table. |
| 459 | ;; abbrev expansion. | 468 | ;; - Then we do a trick which tells the expand-abbrev frame |
| 460 | ;; - Then we call expand-abbrev again, recursively, to do the abbrev | 469 | ;; which invoked us to not continue (and thus not |
| 461 | ;; expansion with the above syntax table. | 470 | ;; expand twice.) This means that any abbrev expansion |
| 462 | ;; - Then we do a trick which tells the expand-abbrev frame which | 471 | ;; will happen as a result of this function's call to |
| 463 | ;; invoked us to not continue (and thus not expand twice.) | 472 | ;; expand-abbrev, and not as a result of the call to |
| 464 | ;; This means that any abbrev expansion will happen as a result | 473 | ;; expand-abbrev which invoked *us*. |
| 465 | ;; of this function's call to expand-abbrev, and not as a result | 474 | ;; - Then we set the syntax table to |
| 466 | ;; of the call to expand-abbrev which invoked *us*. | 475 | ;; mail-mode-header-syntax-table, which doesn't have |
| 467 | ;; - Then we set the syntax table to mail-mode-header-syntax-table, | 476 | ;; anything to do with abbrev expansion, but |
| 468 | ;; which doesn't have anything to do with abbrev expansion, but | 477 | ;; is just for the user's convenience (see its doc string.) |
| 469 | ;; is just for the user's convenience (see its doc string.) | 478 | ;; |
| 470 | ;; | 479 | |
| 471 | (setq local-abbrev-table mail-aliases) | 480 | (setq local-abbrev-table mail-aliases) |
| 472 | ;; If the character just typed was non-alpha-symbol-syntax, then don't | 481 | |
| 473 | ;; expand the abbrev now (that is, don't expand when the user types -.) | 482 | ;; If the character just typed was non-alpha-symbol-syntax, |
| 474 | ;; Check the character's syntax in the mail-mode-header-syntax-table. | 483 | ;; then don't expand the abbrev now (that is, don't expand |
| 475 | (set-syntax-table mail-mode-header-syntax-table) | 484 | ;; when the user types -.) Check the character's syntax in |
| 476 | (or (eq (char-syntax last-command-char) ?_) | 485 | ;; the mail-mode-header-syntax-table. |
| 477 | (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop. | 486 | |
| 478 | ;; Use this table so that abbrevs can have hyphens in them. | 487 | (set-syntax-table mail-mode-header-syntax-table) |
| 479 | (set-syntax-table mail-abbrev-syntax-table) | 488 | (or (eq (char-syntax last-command-char) ?_) |
| 480 | (expand-abbrev) | 489 | (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop. |
| 481 | ;; Now set it back to what it was before. | 490 | ;; Use this table so that abbrevs can have hyphens in them. |
| 482 | (set-syntax-table mail-mode-header-syntax-table))) | 491 | (set-syntax-table mail-abbrev-syntax-table) |
| 483 | (setq abbrev-start-location (point) ; This is the trick. | 492 | (expand-abbrev) |
| 484 | abbrev-start-location-buffer (current-buffer)) | 493 | ;; Now set it back to what it was before. |
| 485 | ))) | 494 | (set-syntax-table mail-mode-header-syntax-table))) |
| 495 | (setq abbrev-start-location (point) ; This is the trick. | ||
| 496 | abbrev-start-location-buffer (current-buffer))) | ||
| 497 | |||
| 498 | ;; We're not in a mail header where mail aliases should | ||
| 499 | ;; be expanded, then use the normal mail-mode abbrev table | ||
| 500 | ;; (if any) and the normal mail-mode syntax table. | ||
| 501 | |||
| 502 | (setq local-abbrev-table (and (boundp 'mail-mode-abbrev-table) | ||
| 503 | mail-mode-abbrev-table)) | ||
| 504 | (set-syntax-table mail-mode-syntax-table)) | ||
| 505 | )) | ||
| 486 | 506 | ||
| 487 | ;;; utilities | 507 | ;;; utilities |
| 488 | 508 | ||
| @@ -619,8 +639,7 @@ end of line." | |||
| 619 | (abbrev-mode 1))) | 639 | (abbrev-mode 1))) |
| 620 | 640 | ||
| 621 | 641 | ||
| 622 | (cond ((or (string-match "^18\\." emacs-version) | 642 | (cond ((string-match "^18\\." emacs-version) |
| 623 | (and (boundp 'epoch::version) epoch::version)) | ||
| 624 | ;; | 643 | ;; |
| 625 | ;; v19 (and this code) uses a new name for this function. | 644 | ;; v19 (and this code) uses a new name for this function. |
| 626 | (or (fboundp 'buffer-disable-undo) | 645 | (or (fboundp 'buffer-disable-undo) |
| @@ -670,8 +689,8 @@ end of line." | |||
| 670 | (symbol-function 'vm-mail-internal))) | 689 | (symbol-function 'vm-mail-internal))) |
| 671 | (fset 'vm-mail-internal | 690 | (fset 'vm-mail-internal |
| 672 | (function (lambda (&rest args) | 691 | (function (lambda (&rest args) |
| 673 | (apply 'vm-mail-internal-v18 args) | 692 | (mail-aliases-setup-v18) |
| 674 | (mail-aliases-setup-v18)))))) | 693 | (apply 'vm-mail-internal-v18 args)))))) |
| 675 | 694 | ||
| 676 | ;; If we're being loaded from mail-setup-hook or mail-mode-hook | 695 | ;; If we're being loaded from mail-setup-hook or mail-mode-hook |
| 677 | ;; as run from inside mail-setup or vm-mail-internal, then install | 696 | ;; as run from inside mail-setup or vm-mail-internal, then install |