Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab does not auto-complete emails in the To: field #166

Open
DrWaleedAYousef opened this issue May 7, 2023 · 16 comments
Open

Tab does not auto-complete emails in the To: field #166

DrWaleedAYousef opened this issue May 7, 2023 · 16 comments

Comments

@DrWaleedAYousef
Copy link

I am using spacemacs + gnus layer + gnus + org mode layer + org-msg

Tab never autocomplete emails. I tried several configurations, including those suggested in the help page here on the repo.

Without org-msg Tab does autocomplete but after I open Org-Contacts.

@david-alvarez-rosa
Copy link

Plausible reason is that whatever your config is might be assuming message-mode-map when setting up the bindings. For org-msg you must use the equivalent org-msg-edit-mode-map.

@DrWaleedAYousef
Copy link
Author

Sorry, could you elaborate? I checked, TAB is already bound to org-msg-tab

@david-alvarez-rosa
Copy link

In my particular case I use EDUC and have this binding working correctly (ref):

(bind-key "<M-tab>" 'eudc-expand-inline org-msg-edit-mode-map)

@DrWaleedAYousef
Copy link
Author

For more clarification, that TAB works well when I am at the Gcc: field. When I press TAB helm pops up all the groups and I can select. The problem seems to be the org-contacts or something like that not the mode-map.

@abougouffa
Copy link
Contributor

abougouffa commented Jun 5, 2023

I have the same issue. Auto-completion of emails stopped working two or three weeks ago.

@jonathanwilner
Copy link

I use the great Minemacs curated by @abougouffa.

I took the advice of @david-alvarez-rosa above and set the keybinding. In my case, I chose to use notmuch-company.

(define-key org-msg-edit-mode-map [tab] #'notmuch-company)

@abougouffa
Copy link
Contributor

abougouffa commented Jun 6, 2023

@jonathanwilner I'm using org-msg with mu4e (I guess notmuch-company works with notmuch). Normally, mu4e supports auto-completion out of the box. However, when org-msg-edit-mode is activated, it doesn't work. In MinEmacs, it should be solved now (for mu4e).

@DrWaleedAYousef In my case, after some digging, it turned out that I was overwriting the completion-at-point-functions in modes derived from org-mode. I fixed it and it is working now. To test this, you can evaluate M-: completion-at-point-functions to see its value. If you don't see mu4e~compose-complete-contact in the list, it can be a similar problem. You can drop this in your config for a quick fix, however, it is recommended to search the real cause of the issue (in my case, I was altering completion-at-point-functions when running tempel-mode in modes derived from org-mode).

(add-hook 'org-msg-edit-mode-hook #'mu4e~compose-complete-contact)

abougouffa added a commit to abougouffa/minemacs that referenced this issue Jun 6, 2023
This fixes the issue I was facing with `org-msg`, similar to this one:
jeremy-compostella/org-msg#166
@DrWaleedAYousef
Copy link
Author

Sorry, I am confused. So what do you suggest for my configurations I mentioned upfront? Thanks.

@abougouffa
Copy link
Contributor

Just drop (add-hook 'org-msg-edit-mode-hook #'mu4e~compose-complete-contact) in your configuration file. I don't know what are the conventions in Spacemacs to do such a thing.

@DrWaleedAYousef
Copy link
Author

Just drop (add-hook 'org-msg-edit-mode-hook #'mu4e~compose-complete-contact) in your configuration file. I don't know what are the conventions in Spacemacs to do such a thing.

I am using gnus not mu4e. I tried everything, and did not work!

@DrWaleedAYousef
Copy link
Author

@jeremy-compostella could you please help. I see you already use gnus as myself. Do you have any advice?

@jeremy-compostella
Copy link
Owner

@jeremy-compostella could you please help. I see you already use gnus as myself. Do you have any advice?

I also indeed use gnus and it works fine for me. TAB is bound org-msg-tab and when I am on a recipient field I can complete emails using this key. As you see in the org-msg-tab is a very small function which just call message-tab. I am wondering if it works for you when you disable org-msg, create a new message buffer, go to a recipient field and do a M-x message-tab. If it does not work that's probably what you need to fix and this is not related to org-msg.

@cnoceda
Copy link

cnoceda commented Jun 25, 2024

Hi, I'm having the same trouble. I'm using notmuch. If I disable org-msg-mode works with no problem, but with org-msg-mode active sometimes only work the first time and then no more. It's very estrange because I read the function and it has nothing special. If I call M-x org-msg-tab it doesn't work.

is there a way to debug this kind of behaviour?

Edit org-msg-tab it's working good. The thing it's message-tab doesn't seem to work. Probably completion-at-point

With org-msg-mode disabled, both functions work well. It seems like when the org-msg-mode is enabled completion-at-point stops working.

Edit 2024-06-26
The problem is completion-at-point decide the completion function with this command:
(run-hook-wrapped 'completion-at-point-functions #'completion--capf-wrapper 'all)
When org-msg-mode is enable it return nil. When is disable returns the correct function and the other params.
The var completion-at-point-functions is a special hook to find the completion-function message-completion-function it's first function in the list, if you add org-contacts-message-complete-function to the hook, it works perfect. I try message-completion-function by it self and it seems to work correctly returning the completion function.
I notice that the return format of both, org-contacts-message-complete-function and message-completion-function it's different. Could be the problem?

@cnoceda
Copy link

cnoceda commented Jul 16, 2024

Hi, I'm having the same trouble. I'm using notmuch. If I disable org-msg-mode works with no problem, but with org-msg-mode active sometimes only work the first time and then no more. It's very estrange because I read the function and it has nothing special. If I call M-x org-msg-tab it doesn't work.

is there a way to debug this kind of behaviour?

Edit org-msg-tab it's working good. The thing it's message-tab doesn't seem to work. Probably completion-at-point

With org-msg-mode disabled, both functions work well. It seems like when the org-msg-mode is enabled completion-at-point stops working.

Edit 2024-06-26 The problem is completion-at-point decide the completion function with this command: (run-hook-wrapped 'completion-at-point-functions #'completion--capf-wrapper 'all) When org-msg-mode is enable it return nil. When is disable returns the correct function and the other params. The var completion-at-point-functions is a special hook to find the completion-function message-completion-function it's first function in the list, if you add org-contacts-message-complete-function to the hook, it works perfect. I try message-completion-function by it self and it seems to work correctly returning the completion function. I notice that the return format of both, org-contacts-message-complete-function and message-completion-function it's different. Could be the problem?

I found the problem. It's a notmuch-address-expand-name. For any reason, it only works the first time I use the autocompletion. Probably the pattern is not good. I don't know, I have to do more research. But I'm going to open an issue with notmuch.

Sorry and thank you!

@cnoceda
Copy link

cnoceda commented Jul 18, 2024

Hi, I'm having the same trouble. I'm using notmuch. If I disable org-msg-mode works with no problem, but with org-msg-mode active sometimes only work the first time and then no more. It's very estrange because I read the function and it has nothing special. If I call M-x org-msg-tab it doesn't work.
is there a way to debug this kind of behaviour?
Edit org-msg-tab it's working good. The thing it's message-tab doesn't seem to work. Probably completion-at-point
With org-msg-mode disabled, both functions work well. It seems like when the org-msg-mode is enabled completion-at-point stops working.
Edit 2024-06-26 The problem is completion-at-point decide the completion function with this command: (run-hook-wrapped 'completion-at-point-functions #'completion--capf-wrapper 'all) When org-msg-mode is enable it return nil. When is disable returns the correct function and the other params. The var completion-at-point-functions is a special hook to find the completion-function message-completion-function it's first function in the list, if you add org-contacts-message-complete-function to the hook, it works perfect. I try message-completion-function by it self and it seems to work correctly returning the completion function. I notice that the return format of both, org-contacts-message-complete-function and message-completion-function it's different. Could be the problem?

I found the problem. It's a notmuch-address-expand-name. For any reason, it only works the first time I use the autocompletion. Probably the pattern is not good. I don't know, I have to do more research. But I'm going to open an issue with notmuch.

Sorry and thank you!

Hi again, I found the problem with autocompletion. The problem is with the message-completion-function . The first time works perfect, but the second time stops to work. The cause is because the first time the completion function, notmuch-address-expand-name in my case, is stored in message--old-style-completion-functions. The second time if the function is in the variable, executes a lambda function instead a progn so its return a function instead a value of completion.
So, if you have some issues, look here first.
Workaround copy message-completion-function in your init.el and make the change. And keep in mind you have to watch updates in the message.el package
Regards

@jeremy-compostella
Copy link
Owner

Can't you make an upstream-able fix ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants