From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/8951 Path: main.gmane.org!not-for-mail From: Kai Grossjohann Newsgroups: gmane.emacs.gnus.general Subject: Re: Keymap in message mode? Date: 25 Nov 1996 15:30:36 +0100 Sender: grossjoh@charly.informatik.uni-dortmund.de Message-ID: References: Reply-To: Kai Grossjohann NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035149052 15577 80.91.224.250 (20 Oct 2002 21:24:12 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 21:24:12 +0000 (UTC) Cc: ding@ifi.uio.no Return-Path: Original-Received: (qmail 5249 invoked from smtpd); 25 Nov 1996 15:01:57 -0000 Original-Received: from ifi.uio.no (0@129.240.64.2) by deanna.miranova.com with SMTP; 25 Nov 1996 15:01:55 -0000 Original-Received: from fbi-mail.informatik.uni-dortmund.de (fbi-mail.informatik.uni-dortmund.de [129.217.4.42]) by ifi.uio.no with ESMTP (8.6.11/ifi2.4) id for ; Mon, 25 Nov 1996 15:31:09 +0100 Original-Received: from lucy.informatik.uni-dortmund.de (lucy.informatik.uni-dortmund.de [129.217.20.160]) by fbi-mail.informatik.uni-dortmund.de (8.8.2/) with SMTP id PAA22066; Mon, 25 Nov 1996 15:30:38 +0100 (MET) Original-Received: by lucy.informatik.uni-dortmund.de id PAA23689; Mon, 25 Nov 1996 15:30:37 +0100 Original-To: jens@lemcbed.lem.uni-karlsruhe.de In-Reply-To: Jens Lautenbacher's message of 25 Nov 1996 16:43:09 +0100 Original-Lines: 67 X-Mailer: Red Gnus v0.70/Emacs 19.34 Xref: main.gmane.org gmane.emacs.gnus.general:8951 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:8951 >>>>> Jens Lautenbacher writes: Jens> Sometime ago, if I remember correctly, someone posted a piece Jens> of code which changed the behaviour of the M-Tab in the header Jens> of a message according to the current headerline(so one could Jens> bind it in the to line to bbdb-complete-foo-bar and in the Jens> newsgroup line it would do a complete over the newsgroups.) That may have been me. Used TAB tho, rather than M-TAB. kai -- I wonder why nobody don't like me, or is it de fact dat I'm ugly? -- Harry Belafonte ;; message-x.el -- customizable completion in message headers ;; Kai Grossjohann ;; 9 Aug 96 (require 'message) (defvar message-x-body-function 'indent-relative "message-x-tab executes this if point is in the body of a message.") (defvar message-x-completion-alist '(("to" . bbdb-complete-name) ("cc" . bbdb-complete-name) ("newsgroups" . message-expand-group)) "Table telling which completion function message-x-tab should invoke. Lookup in the table is done with `equal' comparison of the header.") (defun message-x-in-header-p () "Returns t iff point is in the header section." (save-excursion (let ((p (point))) (beginning-of-buffer) (and (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$")) (progn (beginning-of-line) t) (< p (point)))))) (defun message-x-which-header () "Returns the header we're currently in. Returns nil if not in a header. Example: returns \"to\" if we're in the \"to\" header right now." (and (message-x-in-header-p) (save-excursion (beginning-of-line) (while (looking-at "^[ \t]+") (forward-line -1)) (looking-at "\\([^:]+\\):") (downcase (buffer-substring-no-properties (match-beginning 1) (match-end 1)))))) (defun message-x-tab () "Does completion based on header currently in or executes a default function in the body." (interactive) (let ((header (assoc (message-x-which-header) message-x-completion-alist))) (funcall (if header (cdr header) message-x-body-function)))) (define-key message-mode-map "\t" 'message-x-tab) (provide 'message-x) ;; message-x ends here