* mc-expand-mail-abbrev
@ 2005-09-10 1:12 Michael Cook
2005-09-17 18:39 ` mc-expand-mail-abbrev Michael Cook
0 siblings, 1 reply; 4+ messages in thread
From: Michael Cook @ 2005-09-10 1:12 UTC (permalink / raw)
when using S D r (gnus-summary-resend-message), it'd be nice to be
able to expand mail aliases and to complete via bbdb.
so, i took a stab at it. i think my solution is not quite right
yet, but it seems to be close. any thoughts?
(defun mc-expand-mail-abbrev (arg)
"Expand the mail abbreviation before point."
(interactive "P")
(save-restriction
(if mark-active
(narrow-to-region (region-beginning) (region-end))
(let ((syntax-table (syntax-table)))
(narrow-to-region (unwind-protect
(save-excursion
(set-syntax-table mail-abbrev-syntax-table)
(backward-word 1)
(point))
(set-syntax-table syntax-table))
(point))))
(goto-char (point-max))
(let ((point-was (point)))
(mail-abbrev-insert-alias (buffer-substring (point-min) (point-max)))
(or (= (point) point-was)
(delete-region (point-min) point-was)))
(bbdb-complete-name arg)))
(define-key minibuffer-local-map "\M-," 'mc-expand-mail-abbrev)
(define-key message-mode-map "\M-," 'mc-expand-mail-abbrev)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mc-expand-mail-abbrev
2005-09-10 1:12 mc-expand-mail-abbrev Michael Cook
@ 2005-09-17 18:39 ` Michael Cook
2005-09-18 10:42 ` mc-expand-mail-abbrev Reiner Steib
0 siblings, 1 reply; 4+ messages in thread
From: Michael Cook @ 2005-09-17 18:39 UTC (permalink / raw)
> when using S D r (gnus-summary-resend-message), it'd be nice to be
> able to expand mail aliases and to complete via bbdb.
>
> so, i took a stab at it. i think my solution is not quite right
> yet, but it seems to be close. any thoughts?
here's a better version.
(defun mc-expand-mail-abbrev (arg)
"Expand the mail abbreviation before point."
(interactive "P")
;; See what is between point and the preceding newline, colon or comma.
;; If it's a single word, then attempt to expand it using "mail-abbrev".
(let* ((end (point))
(beg (save-excursion
(re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
(goto-char (match-end 0))
(point)))
(typed (buffer-substring beg end)))
(when (string-match "^\\w+$" typed)
(mail-abbrev-insert-alias typed)
(or (= (point) end)
(delete-region beg end))))
;; Now try BBDB completion.
(bbdb-complete-name arg))
(define-key minibuffer-local-map "\M-," 'mc-expand-mail-abbrev)
(define-key message-mode-map "\M-," 'mc-expand-mail-abbrev)
m.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mc-expand-mail-abbrev
2005-09-17 18:39 ` mc-expand-mail-abbrev Michael Cook
@ 2005-09-18 10:42 ` Reiner Steib
2005-09-18 22:04 ` mc-expand-mail-abbrev Michael Cook
0 siblings, 1 reply; 4+ messages in thread
From: Reiner Steib @ 2005-09-18 10:42 UTC (permalink / raw)
On Sat, Sep 17 2005, Michael Cook wrote:
>> when using S D r (gnus-summary-resend-message), it'd be nice to be
>> able to expand mail aliases and to complete via bbdb.
ACK
>> so, i took a stab at it. i think my solution is not quite right
>> yet, but it seems to be close. any thoughts?
[...]
> (defun mc-expand-mail-abbrev (arg)
> "Expand the mail abbreviation before point."
> (interactive "P")
> ;; See what is between point and the preceding newline, colon or comma.
> ;; If it's a single word, then attempt to expand it using "mail-abbrev".
[...]
> ;; Now try BBDB completion.
> (bbdb-complete-name arg))
> (define-key minibuffer-local-map "\M-," 'mc-expand-mail-abbrev)
> (define-key message-mode-map "\M-," 'mc-expand-mail-abbrev)
Wouldn't it be better to hook `message-expand-name' into
`message-minibuffer-local-map'? See `message-read-from-minibuffer'.
(I didn't try, so maybe this is nonsense.)
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mc-expand-mail-abbrev
2005-09-18 10:42 ` mc-expand-mail-abbrev Reiner Steib
@ 2005-09-18 22:04 ` Michael Cook
0 siblings, 0 replies; 4+ messages in thread
From: Michael Cook @ 2005-09-18 22:04 UTC (permalink / raw)
> when using S D r (gnus-summary-resend-message), it'd be nice to be
> able to expand mail aliases and to complete via bbdb.
turns out the previous version didn't behave well when
mail-abbrev-insert-alias decided to evoke auto-fill. the following
version doesn't have that problem. also, i've incorporated reiner
steib's suggestion to use message-minibuffer-local-map.
(defun mc-expand-mail-abbrev (arg)
"Expand the mail abbreviation before point."
(interactive "P")
;; See what is between point and the preceding newline, colon or comma. If
;; it's in the mail-abbrev table, replace it.
(or (vectorp mail-abbrevs)
(mail-abbrevs-setup))
(let* ((end (point))
(beg (save-excursion
(re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
(goto-char (match-end 0))
(point)))
(abbrev (symbol-value (intern-soft (buffer-substring beg end)
mail-abbrevs))))
(when abbrev
(delete-region beg end)
(insert abbrev)))
;; Now try BBDB completion.
(bbdb-complete-name arg))
(define-key message-minibuffer-local-map "\M-," 'mc-expand-mail-abbrev)
(define-key message-mode-map "\M-," 'mc-expand-mail-abbrev)
m.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-09-18 22:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-10 1:12 mc-expand-mail-abbrev Michael Cook
2005-09-17 18:39 ` mc-expand-mail-abbrev Michael Cook
2005-09-18 10:42 ` mc-expand-mail-abbrev Reiner Steib
2005-09-18 22:04 ` mc-expand-mail-abbrev Michael Cook
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).