rougier / mu4e-dashboard

A dashboard for mu4e (mu for emacs)
GNU General Public License v3.0
467 stars 43 forks source link

shelling out to "mu find" is brittle and should be replaced #5

Open stsquad opened 3 years ago

stsquad commented 3 years ago

I'm finding a bunch of my queries are not updating because of escaping issues when calling (shell-command-to-string) with my default shell (fish). At a minimum it would probably make sense to factor out all the queries to a single common function where we can be sure of getting the escaping right. However going forward we should investigate if @djcb could consider an public API to make queries of the "mu" daemon which already has the database loaded in memory and could probably just count the number of hits for you and respond with that.

rougier commented 3 years ago

Using the mu daemon would be much nicer rather than calling mu through shell. I've no real idea on how to do that though.

agpchil commented 3 years ago

(Disclaimer: I'm the author of mu4e-maildirs-extension)

I had to use shell commands when I wrote mu4e-maildirs-extension and it gave me lots of troubles. So I also agree with @stsquad that it is better to avoid it if possible.

AFAIK it is now possible to fetch unread/total counts via the daemon. I think you need to pass the list of queries to mu4e~proc-ping and after the pong is processed the results are stored in mu4e~server-props variable (see also mu4e~main-bookmarks function for an example).

Hope this helps, although I haven't followed the mu development so I may be wrong.

stsquad commented 3 years ago

I've raised https://github.com/djcb/mu/issues/1845 to see what @djcb might have to say about it.

rougier commented 3 years ago

Thanks. Let's wait for an answer.