Gnus development mailing list
 help / color / mirror / Atom feed
* New version of message-tab
@ 1996-08-09 17:42 Kai Grossjohann
  1996-08-09 17:44 ` Kai Grossjohann
  1996-08-28  6:50 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Kai Grossjohann @ 1996-08-09 17:42 UTC (permalink / raw)


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 v\bve\ber\bry\by 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 <grossjohann@ls6.informatik.uni-dortmund.de>
;;  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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: New version of message-tab
  1996-08-09 17:42 New version of message-tab Kai Grossjohann
@ 1996-08-09 17:44 ` Kai Grossjohann
  1996-08-28  6:50 ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Kai Grossjohann @ 1996-08-09 17:44 UTC (permalink / raw)
  Cc: Ding-Gnus Mailing List

>>>>> Kai Grossjohann writes:

  Kai> Be careful: the header values are NOT strings,

Grmbl.  Of course, I wanted to say that they're not regexps!

  Kai> comparison is done using `equal'.  Therefore, "to\\|cc" refers
  Kai> to a very strange header, not to both the To and Cc headers!

I must be tired,
kai
-- 
What's a signature?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: New version of message-tab
  1996-08-09 17:42 New version of message-tab Kai Grossjohann
  1996-08-09 17:44 ` Kai Grossjohann
@ 1996-08-28  6:50 ` Lars Magne Ingebrigtsen
  1996-08-28 22:48   ` Paul Franklin
  1996-09-25 13:53   ` Kai Grossjohann
  1 sibling, 2 replies; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 1996-08-28  6:50 UTC (permalink / raw)


Kai Grossjohann <grossjohann@ls6.informatik.uni-dortmund.de> writes:

> 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.

Seems quite useful, but I'm not sure whether to include it in the
distribution or not.  This sort of thing should ideally be handled
outside Message itself -- `mail-abbrev' does things nicely, and `bbdb'
does other things nicely.  I think the Newsgroups expansion should
also be moved out to a separate package, perhaps.

-- 
  "Yes.  The journey through the human heart 
     would have to wait until some other time."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: New version of message-tab
  1996-08-28  6:50 ` Lars Magne Ingebrigtsen
@ 1996-08-28 22:48   ` Paul Franklin
  1996-09-25 13:53   ` Kai Grossjohann
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Franklin @ 1996-08-28 22:48 UTC (permalink / raw)
  Cc: ding

>>>>> Lars Magne Ingebrigtsen writes:

 > Kai Grossjohann <grossjohann@ls6.informatik.uni-dortmund.de> writes:

 >> 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.

 > Seems quite useful, but I'm not sure whether to include it in the
 > distribution or not.  This sort of thing should ideally be handled
 > outside Message itself -- `mail-abbrev' does things nicely, and `bbdb'
 > does other things nicely.  I think the Newsgroups expansion should
 > also be moved out to a separate package, perhaps.

Hmm.  If all Kai has done is provided a nice interface for other
packages to attach themselves to this part of Message, then it makes
sense to me to include it.  Of course, the default should probably be
an empty alist.

Then Gnus could even add a Newsgroups expansion as it starts up.  :)

--Paul


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: New version of message-tab
  1996-08-28  6:50 ` Lars Magne Ingebrigtsen
  1996-08-28 22:48   ` Paul Franklin
@ 1996-09-25 13:53   ` Kai Grossjohann
  1 sibling, 0 replies; 5+ messages in thread
From: Kai Grossjohann @ 1996-09-25 13:53 UTC (permalink / raw)


>>>>> Lars Magne Ingebrigtsen writes:

  Lars> Seems quite useful, but I'm not sure whether to include it in
  Lars> the distribution or not.

Well, as it is now, it's a separate file message-x.el.  The only thing
that prevents this from being used in the mh-e or rmail or VM
composition modes is the default value of the alist.

Well, I'll remove the references to Gnus and message.el, call it
mail-header-expand.el or something and post it to g.e.s.  Though it's
only 50 lines...

  Lars> [...]I think the Newsgroups expansion should
  Lars> also be moved out to a separate package, perhaps.

Seems to be kinda difficult because of the strong dependence on a list
of newsgroups?

kai "back from vacation"
-- 
Life is hard and then you die.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1996-09-25 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-09 17:42 New version of message-tab Kai Grossjohann
1996-08-09 17:44 ` Kai Grossjohann
1996-08-28  6:50 ` Lars Magne Ingebrigtsen
1996-08-28 22:48   ` Paul Franklin
1996-09-25 13:53   ` Kai Grossjohann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).