Mercurial > emacs
changeset 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 | f7eed599c0df |
children | ddc6811eb4c8 |
files | lisp/mail/mailabbrev.el |
diffstat | 1 files changed, 35 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mail/mailabbrev.el Wed May 03 19:24:18 2000 +0000 +++ b/lisp/mail/mailabbrev.el Wed May 03 19:25:07 2000 +0000 @@ -1,6 +1,7 @@ ;;; mailabbrev.el --- abbrev-expansion of mail aliases. -;; Copyright (C) 1985, 86, 87, 92, 93, 96, 1997 Free Software Foundation, Inc. +;; Copyright (C) 1985, 86, 87, 92, 93, 96, 1997, 2000 +;; Free Software Foundation, Inc. ;; Author: Jamie Zawinski <jwz@lucid.com>, now <jwz@jwz.org> ;; Maintainer: FSF @@ -49,7 +50,7 @@ ;; If auto-fill mode is on, abbrevs will wrap at commas instead of at word ;; boundaries; also, header continuation-lines will be properly indented. ;; -;; You can also insert a mail alias with mail-interactive-insert-alias +;; You can also insert a mail alias with mail-abbrev-insert-alias ;; (bound to C-c C-a), which prompts you for an alias (with completion) ;; and inserts its expansion at point. ;; @@ -554,7 +555,7 @@ (setq mail-abbrevs nil) (build-mail-abbrevs file)) -(defun mail-interactive-insert-alias (&optional alias) +(defun mail-abbrev-insert-alias (&optional alias) "Prompt for and insert a mail alias." (interactive (progn (if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup)) @@ -563,6 +564,34 @@ (insert (or (and alias (symbol-value (intern-soft alias mail-abbrevs))) "")) (mail-abbrev-expand-hook)) +(defun mail-abbrev-complete-alias () + "Perform completion on alias preceding point." + ;; Based on lisp.el:lisp-complete-symbol + (interactive) + (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) + (message "Making completion list...done")))))))) + (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, @@ -597,7 +626,9 @@ (setq this-command 'end-of-buffer) (end-of-buffer arg)) -(define-key mail-mode-map "\C-c\C-a" 'mail-interactive-insert-alias) +(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) ;;(define-key mail-mode-map "\C-n" 'mail-abbrev-next-line) ;;(define-key mail-mode-map "\M->" 'mail-abbrev-end-of-buffer)