[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flyspell mode and BBDB autocompletion



Alex Kavanagh wrote:

> At Wed, 20 Jul 2005 08:00:13 -0400,
> Ron Isaacson wrote:
> >
> > Alex Kavanagh wrote:
> > >
> > > At Tue, 19 Jul 2005 07:24:37 -0400,
> > > Ron Isaacson wrote:
> > > >
> > > > Alex Kavanagh wrote:
> > > > >
> > > > > Hello
> > > > >
> > > > > Does anyone know how to configure Wanderlust to work with
> > > > > flyspell-mode and BBDB autocompletion in the To: Cc: and Bcc: headers?
> > > > > I can't seem to work out how to get the two to play along nicely as
> > > > > they both want M-TAB and flyspell wins (probably bound earlier).
> > > >
> > > > Actually, the later binding normally takes precedence. Take a look at
> > > > wl-draft-beginning-of-line (C-a), which does different things on
> > > > header and body lines, based on wl-draft-point-in-header-p. You could
> > > > simply write your own function which calls different auto-completion
> > > > functions based on the same condition (or even more specifically,
> > > > calls bbdb iff in the to/cc/bcc header), and bind that to M-TAB...
> > >
> > > Thanks for the info. I'm not sure if my elisp is up to the task yet.
> > > I've done some Scheme programming but nothing in elisp apart from
> > > configuration settings in .wl and .emacs but I will have a look and
> > > see if I can do something with it. Thanks for the pointer.
> >
> > Ahh ok... this sounds like a good learning experience then. :-)
> >
> > This should be a fairly easy one to start with, since you can copy at
> > least some of what you need from wl-draft-beginning-of-line. Let me
> > know if you need any help!
> 
> Ok. This is what I came up with and it seems to work quite well.
> However, I don't know if moving the point around and regex searching
> is the best way of doing it?? Oh, well, it might help somebody else
> as well.
> 
> In my .wl after bbdb is set up.
> 
> ;; Handle bbdb and ispell in the same buffer (message)
> 
> (defun ajk/wl-m-tab ()
>   "A hook for M-TAB in Wanderlust message composition
>   windows. This function either chooses an ispell word selection
>   or a bbdb email address completion depending on whether the
>   point is in the header or in the main body text."
>   (interactive)
>   (if (and (wl-draft-point-in-header-p)
> 	   (let* ((here (point))
> 		  (eol (line-end-position))
> 		  (bc (progn
> 			(goto-char (line-beginning-position))
> 			(re-search-forward "^.\\(o\\|c\\|cc\\): " eol t))))
> 	     (progn
> 	       (goto-char here)
> 	       bc)))
>       (bbdb-complete-name)
>     (flyspell-auto-correct-word)))
> 
> (define-key wl-draft-mode-map [M-tab] 'ajk/wl-m-tab)
> 
> I know that this won't work for multi-line To:'s etc. and I'm going to
> change the regex to look for spaces or a tab at the beginning of a
> header line (blunt, but it should work).

I've just got this working with my current set up. I found that M-TAB
was bound to mail-abbrev-complete-alias because mailabbrev has an
eval-after-load for sendmail (which I use) which was binding that
function to "\e\t" in mail-mode-map. It seems that M-TAB gets
translated to this keybinding and thus my addition of ajk/wl-m-tab to
wl-draft-mode-map was effectively shadowed. So I altered Alex's code,
replacing the define-key with this:

(add-hook 'wl-draft-mode-hook (lambda () (define-key wl-draft-mode-map "\e\t" 'ajk/wl-m-tab)))

Hope that may be of use to someone else one day.

Richard