comparison lisp/mail/mailabbrev.el @ 28803:80075cf72ede

(mail-abbrev-insert-alias): Renamed from mail-interactive-insert-alias. (mail-abbrev-complete-alias): New command. (mail-mode-map): Bind it to `M-TAB'.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 03 May 2000 19:25:07 +0000
parents ab0d5f2bb751
children e559f0aa6b2d
comparison
equal deleted inserted replaced
28802:f7eed599c0df 28803:80075cf72ede
1 ;;; mailabbrev.el --- abbrev-expansion of mail aliases. 1 ;;; mailabbrev.el --- abbrev-expansion of mail aliases.
2 2
3 ;; Copyright (C) 1985, 86, 87, 92, 93, 96, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985, 86, 87, 92, 93, 96, 1997, 2000
4 ;; Free Software Foundation, Inc.
4 5
5 ;; Author: Jamie Zawinski <jwz@lucid.com>, now <jwz@jwz.org> 6 ;; Author: Jamie Zawinski <jwz@lucid.com>, now <jwz@jwz.org>
6 ;; Maintainer: FSF 7 ;; Maintainer: FSF
7 ;; Created: 19 Oct 90 8 ;; Created: 19 Oct 90
8 ;; Keywords: mail 9 ;; Keywords: mail
47 ;; are used in by changing the variable mail-abbrev-mode-regexp. 48 ;; are used in by changing the variable mail-abbrev-mode-regexp.
48 ;; 49 ;;
49 ;; If auto-fill mode is on, abbrevs will wrap at commas instead of at word 50 ;; If auto-fill mode is on, abbrevs will wrap at commas instead of at word
50 ;; boundaries; also, header continuation-lines will be properly indented. 51 ;; boundaries; also, header continuation-lines will be properly indented.
51 ;; 52 ;;
52 ;; You can also insert a mail alias with mail-interactive-insert-alias 53 ;; You can also insert a mail alias with mail-abbrev-insert-alias
53 ;; (bound to C-c C-a), which prompts you for an alias (with completion) 54 ;; (bound to C-c C-a), which prompts you for an alias (with completion)
54 ;; and inserts its expansion at point. 55 ;; and inserts its expansion at point.
55 ;; 56 ;;
56 ;; This file fixes a bug in the old system which prohibited your .mailrc 57 ;; This file fixes a bug in the old system which prohibited your .mailrc
57 ;; file from having lines like 58 ;; file from having lines like
552 (if (null file) 553 (if (null file)
553 (setq file buffer-file-name)) 554 (setq file buffer-file-name))
554 (setq mail-abbrevs nil) 555 (setq mail-abbrevs nil)
555 (build-mail-abbrevs file)) 556 (build-mail-abbrevs file))
556 557
557 (defun mail-interactive-insert-alias (&optional alias) 558 (defun mail-abbrev-insert-alias (&optional alias)
558 "Prompt for and insert a mail alias." 559 "Prompt for and insert a mail alias."
559 (interactive (progn 560 (interactive (progn
560 (if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup)) 561 (if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
561 (list (completing-read "Expand alias: " mail-abbrevs nil t)))) 562 (list (completing-read "Expand alias: " mail-abbrevs nil t))))
562 (if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup)) 563 (if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
563 (insert (or (and alias (symbol-value (intern-soft alias mail-abbrevs))) "")) 564 (insert (or (and alias (symbol-value (intern-soft alias mail-abbrevs))) ""))
564 (mail-abbrev-expand-hook)) 565 (mail-abbrev-expand-hook))
566
567 (defun mail-abbrev-complete-alias ()
568 "Perform completion on alias preceding point."
569 ;; Based on lisp.el:lisp-complete-symbol
570 (interactive)
571 (let* ((end (point))
572 (syntax-table (syntax-table))
573 (beg (unwind-protect
574 (save-excursion
575 (set-syntax-table mail-abbrev-syntax-table)
576 (backward-word 1)
577 (point))
578 (set-syntax-table syntax-table)))
579 (alias (buffer-substring beg end))
580 (completion (try-completion alias mail-abbrevs)))
581 (cond ((eq completion t)
582 (message "%s" alias)) ; confirm
583 ((null completion)
584 (error "[Can't complete \"%s\"]" alias)) ; (message ...) (ding)
585 ((not (string= completion alias))
586 (delete-region beg end)
587 (insert completion))
588 (t (with-output-to-temp-buffer "*Completions*"
589 (display-completion-list
590 (prog2
591 (message "Making completion list...")
592 (all-completions alias mail-abbrevs)
593 (message "Making completion list...done"))))))))
565 594
566 (defun mail-abbrev-next-line (&optional arg) 595 (defun mail-abbrev-next-line (&optional arg)
567 "Expand any mail abbrev, then move cursor vertically down ARG lines. 596 "Expand any mail abbrev, then move cursor vertically down ARG lines.
568 If there is no character in the target line exactly under the current column, 597 If there is no character in the target line exactly under the current column,
569 the cursor is positioned after the character in that line which spans this 598 the cursor is positioned after the character in that line which spans this
595 (interactive "P") 624 (interactive "P")
596 (if (looking-at "[ \t]*\n") (expand-abbrev)) 625 (if (looking-at "[ \t]*\n") (expand-abbrev))
597 (setq this-command 'end-of-buffer) 626 (setq this-command 'end-of-buffer)
598 (end-of-buffer arg)) 627 (end-of-buffer arg))
599 628
600 (define-key mail-mode-map "\C-c\C-a" 'mail-interactive-insert-alias) 629 (define-key mail-mode-map "\C-c\C-a" 'mail-abbrev-insert-alias)
630 (define-key mail-mode-map "\e\t" ; like lisp-complete-symbol
631 'mail-abbrev-complete-alias)
601 632
602 ;;(define-key mail-mode-map "\C-n" 'mail-abbrev-next-line) 633 ;;(define-key mail-mode-map "\C-n" 'mail-abbrev-next-line)
603 ;;(define-key mail-mode-map "\M->" 'mail-abbrev-end-of-buffer) 634 ;;(define-key mail-mode-map "\M->" 'mail-abbrev-end-of-buffer)
604 635
605 (provide 'mailabbrev) 636 (provide 'mailabbrev)