* How do you automatically refile mails with mu4e?
@ 2017-03-20 7:36 Danny YUE
2017-03-20 8:33 ` Joost Kremers
0 siblings, 1 reply; 3+ messages in thread
From: Danny YUE @ 2017-03-20 7:36 UTC (permalink / raw)
To: help-gnu-emacs
Hi guys,
How can you refile the mails without opening any mu4e buffers?
I read the manual and I know that it is possible to define a function to
refile based on something.
But every time I have to mark-and-execute manually, and it sometimes
annoys me.
I would like it to be automatically done: every time the index is
updated, the incoming unread mails are refiled automatically.
My idea is to add something to the mu4e-update-pre-hook.
But I did not found any clue how I can refile mails in the
background, without opening any buffer.
Looking into the code did not really help.
Can anyone help? Thanks in advance.
Danny
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How do you automatically refile mails with mu4e?
2017-03-20 7:36 How do you automatically refile mails with mu4e? Danny YUE
@ 2017-03-20 8:33 ` Joost Kremers
2017-03-20 13:14 ` Danny YUE
0 siblings, 1 reply; 3+ messages in thread
From: Joost Kremers @ 2017-03-20 8:33 UTC (permalink / raw)
To: Danny YUE; +Cc: help-gnu-emacs
On Mon, Mar 20 2017, Danny YUE wrote:
> How can you refile the mails without opening any mu4e buffers?
>
> I read the manual and I know that it is possible to define a
> function to
> refile based on something.
> But every time I have to mark-and-execute manually, and it
> sometimes
> annoys me.
>
> I would like it to be automatically done: every time the index
> is
> updated, the incoming unread mails are refiled automatically.
>
> My idea is to add something to the mu4e-update-pre-hook.
> But I did not found any clue how I can refile mails in the
> background, without opening any buffer.
> Looking into the code did not really help.
>
> Can anyone help? Thanks in advance.
I'm not sure if what you want is possible at all with mu4e
(personally I use my mail provider's file & filtering options,
other people do it locally using something like procmail).
However, mu4e has its own mailing list. I think your best bet
would be to ask your question there.
HTH
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How do you automatically refile mails with mu4e?
2017-03-20 8:33 ` Joost Kremers
@ 2017-03-20 13:14 ` Danny YUE
0 siblings, 0 replies; 3+ messages in thread
From: Danny YUE @ 2017-03-20 13:14 UTC (permalink / raw)
To: Joost Kremers; +Cc: help-gnu-emacs, Danny YUE
Hi,
Thanks for your advice.
Well, I finally managed to accomplish it myself.
For those who might be interested, I post a snippet here to prove that
it does work:
(defun mu4e-refile-search-and-refile (&optional query)
"Search by QUERY and refile them. If QUERY is not given, ask for it."
(interactive)
(save-window-excursion
(while (not query)
(setq query (read-string "[mu4e] Search and refile for: ")))
(let (mu4e-active-p)
;; If there is any buffer currently opened, save it.
(when (or (get-buffer mu4e-refile-header-buffer-name)
(get-buffer "*mu4e-main*"))
(setq mu4e-active-p t)
(mu4e-refile-save-header-buffer))
;; Search the message and refile.
;; We have to wait until mu4e has finished its job.
(mu4e~headers-search-execute query t)
(while (not (mu4e-refile-finished-p))
(sleep-for 0.1))
(mu4e-refile-current-buffer)
(kill-buffer)
;; If mu4e is active, kill current buffer and restore mu4e
session.
(when mu4e-active-p
(mu4e-refile-restore-header-buffer)))))
Then I added this line to my config file:
(add-hook 'mu4e-index-updated-hook 'mu4e-refile-unread)
After that every time I get a new mail, mu4e will automatically refile
incoming files according to mu4e-refile-folder function.
For a complete version please see:
https://github.com/sheepduke/mu4e-refile
Thanks anyway.
Danny
On 2017-03-20 08:33, Joost Kremers <joostkremers@fastmail.fm> wrote:
> On Mon, Mar 20 2017, Danny YUE wrote:
>> How can you refile the mails without opening any mu4e buffers?
>>
>> I read the manual and I know that it is possible to define a
>> function to
>> refile based on something.
>> But every time I have to mark-and-execute manually, and it
>> sometimes
>> annoys me.
>>
>> I would like it to be automatically done: every time the index
>> is
>> updated, the incoming unread mails are refiled automatically.
>>
>> My idea is to add something to the mu4e-update-pre-hook.
>> But I did not found any clue how I can refile mails in the
>> background, without opening any buffer.
>> Looking into the code did not really help.
>>
>> Can anyone help? Thanks in advance.
>
> I'm not sure if what you want is possible at all with mu4e
> (personally I use my mail provider's file & filtering options,
> other people do it locally using something like procmail).
>
> However, mu4e has its own mailing list. I think your best bet
> would be to ask your question there.
>
> HTH
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-20 13:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-20 7:36 How do you automatically refile mails with mu4e? Danny YUE
2017-03-20 8:33 ` Joost Kremers
2017-03-20 13:14 ` Danny YUE
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 read-only IMAP folder(s) and NNTP newsgroup(s).