Helm and most frequent contacts

41 views
Skip to first unread message

emilio.t...@gmail.com

unread,
Sep 22, 2016, 11:57:31 AM9/22/16
to mu-discuss
Dear mu4e Team,

Thank you very much for this excellent program. I am using the mu4e version 0.9.16, and I see the 'sorted contacts' that I want used with helm. I attach a minimal running example.

My question is about using internal functions:
(mu4e~sort-contacts-for-completion (hash-table-keys mu4e~contacts))
Is there other alternative to use the sorted contacts?
Best regards
Emilio

(require 'helm)
(require '
helm-config)
(require 'subr-x); hash tables

(defun etm-mu4e-helm-contacts ()
  "Get the most frequent contacts from mu4e with helm"
  (interactive)
  (let ((contact (helm :sources (helm-build-sync-source "Search contacts with mu"
                                  :candidates (mu4e~sort-contacts-for-completion
                                               (hash-table-keys mu4e~contacts))
                                  ;;:fuzzy-match t)
                                  )
                       :buffer "*mu4e helm contacts*"
                       :candidate-number-limit 500)))
    (insert (replace-regexp-in-string "\"" "" contact))))



Eduardo Mercovich

unread,
Sep 23, 2016, 1:56:07 PM9/23/16
to mu-di...@googlegroups.com
Hi Emilio

> [...] I see the 'sorted contacts' that I want used with
> helm. I attach a minimal running example. [...]

I can't add anything to this, since I don't know how to program.

However, I'd like to point to another similar solution for your most
used contacts: mail aliases
(https://www.gnu.org/software/emacs/manual/html_node/emacs/Mail-Aliases.html).

The great things -or the ones I like- about them is that:

+ they can be very short, and
+ the're perfectly unambiguous.

The result is that your most used addressed are typed fast and without
possible errors, like if one bystanding helm line were selected.

For example, I could define alias like this for lists, people or groups:
mug <mu-di...@googlegroups.com>
orgl <emacs-...@gnu.org>
dcb "Dirk-Jan C. Binnema" <dj...@djcbsoftware.nl>
avar "Ævar Arnfjörð Bjarmason" <ava...@gmail.com>
pals "Harry Potter" <ha...@magic.org>, "Hellboy" <r...@beasts.com>, "Skywalker" <lu...@starwars.com>

It's fast, native to emacs and the ~/.mailrc file is standard. ;)

Best...


PD: Ævar, I just used your case because it has characters that are not
present by default in my dvorak keyboard, there is nothing personal of
course. :)
--
eduardo mercovich

Donde se cruzan tus talentos
con las necesidades del mundo,
ahí está tu vocación.

Dirk-Jan C. Binnema

unread,
Oct 2, 2016, 6:45:00 AM10/2/16
to mu-di...@googlegroups.com
Hi Emilio,

On Thursday Sep 22 2016, emilio torresmanz wrote:

> Dear mu4e Team,
>
> Thank you very much for this excellent program. I am using the mu4e version
> 0.9.16, and I see the 'sorted contacts' that I want used with helm. I
> attach a minimal running example.
>
> My question is about using internal functions:
> (mu4e~sort-contacts-for-completion (hash-table-keys mu4e~contacts))
> Is there other alternative to use the sorted contacts?

You can use the internal function (I can't stop you!), but there's no
guarantee the format won't change and, subsequently, break the
plugin. In fact, the internal format has changed a few times.

There are a number of helm plugins, perhaps people could join their
efforts and create something that could become part of mu4e? That would
make it much easier to keep things working.

Kind regards,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

Alex Bennée

unread,
Jul 26, 2020, 8:25:34 AM7/26/20
to mu-di...@googlegroups.com, Eduardo Mercovich

Eduardo Mercovich <eduardo....@gmail.com> writes:

> Hi Emilio
>
>> [...] I see the 'sorted contacts' that I want used with
>> helm. I attach a minimal running example. [...]
>
> I can't add anything to this, since I don't know how to program.
>
> However, I'd like to point to another similar solution for your most
> used contacts: mail aliases
> (https://www.gnu.org/software/emacs/manual/html_node/emacs/Mail-Aliases.html).
>
> The great things -or the ones I like- about them is that:
>
> + they can be very short, and
> + the're perfectly unambiguous.
>
> The result is that your most used addressed are typed fast and without
> possible errors, like if one bystanding helm line were selected.
>
> For example, I could define alias like this for lists, people or groups:
> mug <mu-di...@googlegroups.com>
> orgl <emacs-...@gnu.org>
> dcb "Dirk-Jan C. Binnema" <dj...@djcbsoftware.nl>
> avar "Ævar Arnfjörð Bjarmason" <ava...@gmail.com>
> pals "Harry Potter" <ha...@magic.org>, "Hellboy" <r...@beasts.com>, "Skywalker" <lu...@starwars.com>
>
> It's fast, native to emacs and the ~/.mailrc file is standard. ;)

So I was trying to get this to work and I have:

(setq mail-personal-alias-file "~/.mailrc")

and looking at what message-tab does is call completion-at-point and:

completion-at-point-functions is a variable defined in
minibuffer.el.gz.

Value in #<buffer *draft*>
(mu4e~compose-complete-contact
message-completion-function
t)

but AFAICT message-completion-function never gets called when I hit TAB.
The mu4e~compose-complete-contact function gets called several times:

mu4e~complete-handler with qemu-plugins nil metadata
mu4e~complete-handler with qemu-plugins nil (boundaries . )
mu4e~complete-handler with nil t

but it seems this stops the next function being called. If I manually
call completion-at-point in *ielm* set to the *draft* buffer I just get:

(completion-at-point)
"Sole match"

Any ideas what's going on?

>
> Best...
>
>
> PD: Ævar, I just used your case because it has characters that are not
> present by default in my dvorak keyboard, there is nothing personal of
> course. :)
> --
> eduardo mercovich
>
> Donde se cruzan tus talentos
> con las necesidades del mundo,
> ahí está tu vocación.


--
Alex Bennée

Eduardo Mercovich

unread,
Jul 27, 2020, 5:26:36 PM7/27/20
to Alex Bennée, mu-di...@googlegroups.com
Hello Alex.

>> [...] I'd like to point to another similar solution for your most
>> used contacts: mail aliases [...]
>> It's fast, native to emacs and the ~/.mailrc file is standard. ;)

> So I was trying to get this to work [...] but AFAICT
> message-completion-function never gets called when I hit TAB. [...]
> Any ideas what's going on?

I believe that you should not use TAB but any char that signals
abbrev-mode to expand the previous chars. A space, comma, or point
should work (at least, it's how it works on my setup, emacs 26.1).

--
Eduardo Mercovich

Donde se cruzan tus talentos
con las necesidades del mundo,
ahí está tu vocación.
(Anónimo)

Alex Bennée

unread,
Jul 27, 2020, 6:49:57 PM7/27/20
to Eduardo Mercovich, mu-di...@googlegroups.com

Eduardo Mercovich <eduardo....@gmail.com> writes:

> Hello Alex.
>
>>> [...] I'd like to point to another similar solution for your most
>>> used contacts: mail aliases [...]
>>> It's fast, native to emacs and the ~/.mailrc file is standard. ;)
>
>> So I was trying to get this to work [...] but AFAICT
>> message-completion-function never gets called when I hit TAB. [...]
>> Any ideas what's going on?
>
> I believe that you should not use TAB but any char that signals
> abbrev-mode to expand the previous chars. A space, comma, or point
> should work (at least, it's how it works on my setup, emacs 26.1).

Ahh calling dabbrev-expand directly works but I was hoping to have it
work seamlessly with mu4e's built in address completion when it can't
find any candidates.

--
Alex Bennée

Eduardo Mercovich

unread,
Jul 29, 2020, 7:12:12 PM7/29/20
to Alex Bennée, mu-di...@googlegroups.com
Hi Alex.

[...]

>> I believe that you should not use TAB but any char that signals
>> abbrev-mode to expand the previous chars. A space, comma, or point
>> should work (at least, it's how it works on my setup, emacs 26.1).

> Ahh calling dabbrev-expand directly works but I was hoping to have it
> work seamlessly with mu4e's built in address completion when it can't
> find any candidates.

Maybe if it doesn't find something to expand it could "pass" the
original string?
:)
Reply all
Reply to author
Forward
0 new messages