From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/7533 Path: main.gmane.org!not-for-mail From: Kai Grossjohann Newsgroups: gmane.emacs.gnus.general Subject: New version of message-tab Date: 09 Aug 1996 19:42:21 +0200 Sender: grossjoh@charly.informatik.uni-dortmund.de Message-ID: Reply-To: Kai Grossjohann NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035147832 7509 80.91.224.250 (20 Oct 2002 21:03:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 21:03:52 +0000 (UTC) Return-Path: ding-request@ifi.uio.no Original-Received: from ifi.uio.no (ifi.uio.no [129.240.64.2]) by deanna.miranova.com (8.7.5/8.6.9) with SMTP id KAA19740 for ; Fri, 9 Aug 1996 10:55:39 -0700 Original-Received: from fbi-mail.informatik.uni-dortmund.de (fbi-mail.informatik.uni-dortmund.de [129.217.4.40]) by ifi.uio.no with ESMTP (8.6.11/ifi2.4) id for ; Fri, 9 Aug 1996 19:44:53 +0200 Original-Received: from lucy.informatik.uni-dortmund.de by fbi-mail.informatik.uni-dortmund.de with SMTP (Sendmail 8.7.5/UniDo 3.15) id TAA21397; Fri, 9 Aug 1996 19:44:51 +0200 (MES) Original-Received: by lucy.informatik.uni-dortmund.de id TAA26725; Fri, 9 Aug 1996 19:42:23 +0200 Original-To: Ding-Gnus Mailing List Original-Lines: 80 X-Mailer: Gnus v5.2.39/Emacs 19.31 Xref: main.gmane.org gmane.emacs.gnus.general:7533 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:7533 Hi all, there is message-tab which I like a lot, but I also think it could be more general. So I tried to hack up something useful. You can set a variable message-x-body-function to a function that TAB should execute when point is in the body of a message. You can set an alist message-x-completion-alist which tells for each header which function should be invoked when TAB is typed. As I use bbdb, the default says to invoke bbdb-complete-name in To and Cc headers. Also, message-expand-group is invoked in a Newsgroups header. Be careful: the header values are NOT strings, comparison is done using `equal'. Therefore, "to\\|cc" refers to a very strange header, not to both the To and Cc headers! How do you like this? Could this be added to Gnus? Or is it in Red Gnus already, in which case I apologize. This is vveerryy ugly code; I don't know why it works, either ;-) regards, kai -- What's a signature? ;; 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.el ends here