auto-complete / popup-el

Visual Popup Interface Library for Emacs
GNU General Public License v3.0
445 stars 96 forks source link

[Feature Request] auto complete email address when in message-mode #100

Closed zw963 closed 8 years ago

zw963 commented 8 years ago

Thanks.

I have a try to write this myself, but it not successful.

poor document or completely example is missing about doing this.

e.g. current exist a list named: mu4e~contacts-for-completion, include all email address I need.

I want to use this list as message-mode auto-mode dictionary How to do this?

Alternatively, following can popup a list, But I don't know how to select highlighted item into buffer.

(popup-menu* mu4e~contacts-for-completion)

Thanks.

zw963 commented 8 years ago

mu4e-contacts-for-completion example, thanks.

("CINSXCIO <jou@ucn062.chenyingwen.ac.cn>" "bviy@126.cn" "RXCINS <uaqwbg@xcn219.winmail.cc>" "春秋航空 <sac@dm.springairlines.com>" "❤zw963❤沈梓云 <thvhynchz@vej.v.a.lovesyour.com>" "李雪编辑 <15614134592@163.com>" "GitCafe <notifier@gitcafe.com>" "CSDN@mx211.edmsend.csdn.net" "⚡2016新年新功能 <emarket@email11.tccemail.info>" "CSDN@mx226.edmsend.csdn.net" "支付宝 <market@dm.mail.alipay.com>" "❤zw963❤偶凝海 <nnk@zgb.e.z.cn-org.com>" "grvey <mail@service.netease.com>" "张治国 <invitations@linkedin.com>" "❤zw963❤闽雨灵 <fzfmia@nhv.v.a.lovesyour.com>" "知乎 <marketing@newsletter2.zhihu.com>" "樊课长 <info@tidewaterco.com>" "Tサイト[Tポイント/Tカード] <mytc@tsite.jp>" "玩转老虎 <zw963@siyua.engdian.com>" "李雪编辑 <lx15373655633@163.com>")
zw963 commented 8 years ago

My another attempt is failed.

(defun select-and-insert-contact ()
  (interactive)
  (let ((popup (popup-create (point) 50 50)))
    (popup-set-list popup mu4e~contacts-for-completion)
    (popup-draw popup)
    (when (popup-selected-item popup) (popup-delete popup))
    ))

my contacts menu can popup, but can not select.

syohex commented 8 years ago

Sorry too late reply. I suppose following code is enough for you.

(defun my/select-and-insert-contact ()
  (interactive)
  (let ((contact (popup-menu* mu4e-contacts-for-completion)))
    (insert contact)))
zw963 commented 8 years ago

I will try later, and will report the result here.

Thanks very much!

zw963 commented 8 years ago

Sorry for late reply.

I have try it, it worked, though it basically useless in this case. to select a email use C-n/C-p from this huge list is a pain.

from emacs help, I found (pop-menu*) seem like support isearch, could you please give me a example about isearch function include?

the best is: Press hot key, my/select-and-insert-contact function, when I input some char, e.g. zw, it will filter out to only element which include zw.

Thanks.

zw963 commented 8 years ago

I am a auto-complete long-term user, i know popup.el several years ago.

But, I could use it until now .. Though, I have so many use case fit for popup.

e.g.

I have some translate library, when I press Alt+T, translate will open a new buffer wnidow, to show translate result, I want to change it to use popup.el, But, not success.

email auto-complete is another case, remember so many email address is pain.

could you please give me some clue about how to learn worked with popup.el? e.g. a simple example about use popup.el, or a piece of code in auto-complete for popup.el ?

Thanks very much.

syohex commented 8 years ago

from emacs help, I found (pop-menu*) seem like support isearch, could you please give me a example about isearch function include?

You can filter candidates by C-s by default as below gif animation. (I found bug of filtering and I fixed it at #101, please upgrade and use latest version).

popup-search

syohex commented 8 years ago

could you please give me some clue about how to learn worked with popup.el? e.g. a simple example about use popup.el, or a piece of code in auto-complete for popup.el ?

Read README.md or reading popup.el or reading package code which requires popup.el(You can find such packages from here), and write small code.

There is author's blog entry, however it is written in Japanese(It has some codes and screenshots)

zw963 commented 8 years ago

You can filter candidates by C-s by default as below gif animation. (I found bug of filtering and I fixed it at #101, please upgrade and use latest version).

Thanks, it worked with C-s now.

I have see so many parameter with popup-menu*:

(list
                       &key
                       point
                       (around t)
                       (width (popup-preferred-width list))
                       (height 15)
                       max-width
                       margin
                       margin-left
                       margin-right
                       scroll-bar
                       symbol
                       parent
                       parent-offset
                       cursor
                       (keymap popup-menu-keymap)
                       (fallback 'popup-menu-fallback)
                       help-delay
                       nowait
                       prompt
                       isearch
                       (isearch-filter 'popup-isearch-filter-list)
                       (isearch-cursor-color popup-isearch-cursor-color)
                       (isearch-keymap popup-isearch-keymap)
                       isearch-callback
                       initial-index
                       &aux menu event)

I wonder if can enable isearch function imediately without C-s when I run my/select-and-insert-contact? this is a problem which Bothering me for a long time.

`

zw963 commented 8 years ago

I settings one variable which control this behavior (auto start isearch or not when popup-menu*), that will the best result I could expect. Thanks.

zw963 commented 8 years ago

I have hacked with remove following code (and isearch) part. https://github.com/auto-complete/popup-el/blob/master/popup.el#L1196-L1203

It can auto start isearch now.

But, I still consider could isearch imediately is a good function for popup.el. Hope popup.el could add this.

syohex commented 8 years ago

But, I still consider could isearch imediately is a good function for popup.el. Hope popup.el could add this.

popup.el is not designed for such case. I suppose you should use helm or ivy or ido-mode instead of popup.el/auto-complete for such use case.

zw963 commented 8 years ago

Thanks, although that not OK.

ido and helm I use heavily. but just for jump or search things. i think copy some content in buffer with ido or helm is so strange ...

when i press TAB, trigger menu, C-s is tedious...

anyway, Thanks for help.