Jan Vroonhof <vroonhof(a)math.ethz.ch> wrote:
Michael Harnois <mdharnois(a)home.com> writes:
>
> (define-key bbdb-mode-map "\M-\t" 'bbdb-complete-name)
>
> in .emacs would do it, but I seem to have been wrong.
Flyspell is a minor mode so the keymap always priority.
I don't think there is an easy way out here, short of removing the
binding from fly-spell altogether.
FWIW, here's a function that I hook in message-setup-hook. It
basically let M-Tab perform flyspell-correction on some headers, and bbdb
completion on others.
;; Because flyspell overrides M-Tab
(defun restore-bbdb-keys ()
"*When composing a message, if both bbdb and flyspell are used, restore the
bbdb key bindings in all headers likely to need name expansion."
(interactive)
(map-extents (lambda (e unused) (delete-extent e))
nil nil nil nil nil 'restore-bbdb-keys t)
(when (and (eq major-mode 'message-mode)
(eq (lookup-key message-mode-map [(meta tab)])
'bbdb-complete-name)
(eq (key-binding [(meta tab)]) 'flyspell-auto-correct-word))
(save-excursion
(let ((limit (progn (search-forward mail-header-separator)
(point-at-bol))))
(make-local-hook 'kill-buffer-hook)
(goto-char 1)
(while (re-search-forward "^\\(\
\\(From\\|Sender\\)\\|\
\\(\\(Mail-Copies-\\)?To\\)\\|\
\\([GBF]?[Cc][Cc]\\)\\|\
\\(Reply-[Tt]o\\)\\)\
: "
limit t)
(let* ((start (point))
(end (or (and (re-search-forward "^[A-Z][^: \n\t]+: " limit t)
(goto-char (point-at-bol)))
limit))
(extent (make-extent start end)))
(set-extent-property extent 'keymap message-mode-map)
(set-extent-property extent 'restore-bbdb-keys t)
(add-hook 'kill-buffer-hook `(lambda () (delete-extent ,extent))
nil t)))
))
))
--
/ / _ _ Didier Verna
http://www.inf.enst.fr/~verna/
- / / - / / /_/ / EPITA / LRDE mailto:didier@epita.fr
/_/ / /_/ / /__ / 14-16 rue Voltaire Tel. +33 (1) 44 08 01 77
94276 Kremlin-Bicêtre cedex Fax. +33 (1) 44 08 01 99