Closed floli closed 8 years ago
That can be done! (probably :P)
I can't test this right know but I think you have 2 options:
Move the Archiv.2014 Doctoral Retreat
and Archiv.2014 LK Oberstdorf
inside Archiv
. This is probably what this extension expects. The directory structure should be something like this:
Archiv/
.. latest/
.... cur/
.... new/
.... tmp/
.. 2014 Doctoral Retreat/
.... cur/
.... new/
.... tmp/
.. 2014 LK Oberstdorf/
.... cur/
.... new/
.... tmp/
Write your own handler. You can customize mu4e-maildirs-extension-propertize-handler mu4e-maildirs-extension-propertize-func
with your own. With this function you can control how the text is formatted. I wrote a simple example (not tested!):
(defun my/custom-folder-hierachy-propertize (item)
"Propertize maildir with folder hierarchy separated by dot using ITEM plist."
(let* ((name (plist-get item :name))
(level (1- (length (split-string name "\\."))))
(indent (make-string (* mu4e-maildirs-extension-submaildir-indent
level)
32)))
(propertize (format "%s\t%s%s %s (%s/%s)\n"
""
indent
mu4e-maildirs-extension-submaildir-separator
(cadr (split-string name "\\."))
(plist-get item :unread)
(plist-get item :total))
'face (cond
((> (plist-get item :unread) 0) 'mu4e-maildirs-extension-maildir-unread-face)
(t 'mu4e-maildirs-extension-maildir-face)))))
(defun my/custom-propertize (item)
"Custom propertize the maildir using ITEM plist."
(let* ((name (plist-get item :name))
(folder-hierachy-p (string-match "\\." name)))
(if folder-hierachy-p
(my/custom-folder-hierachy-propertize item)
(mu4e-maildirs-extension-propertize-unread-only item))))
(setq mu4e-maildirs-extension-propertize-func #'my/custom-propertize)
Ok, I was able to achieve 1) by setting sep=/
within oflfineimap's configuration. Still, maildirs-extension expects this hierarchy:
account1/
submaildir1/
submaildir2/
...
account2/
submaildir1/
submaildir2/
...
It now displays the folder correctly as subfolders of Archive, but the toplevel folders are displayed as different accounts, with a newline between them.
Furthermore, when I move my folder hierarchy into a account subfolder it handles them incorrectly
| Archiv (0/0)
+ Archiv (0/147)
| 2014 Doctoral Retreat (0/17)
| 2014 LK Oberstdorf (0/12)
| 2015 Coupled Problems (0/38)
| 2015 SIAM CSE (0/47)
| 2015 USNCCM (0/33)
| Bulk (2/852)
+ Bulk (4/190)
| GitHub (1/95)
| Pubs (3/95)
notice the double Bulk, Archive.
The account should be top level directories: ~/mail/account1
, ~/mail/account2
. Not sure what happens If you put account1
inside a submaildir folder...
It's possible that the function mu4e-maildirs-extension-get-maildirs
can't get the right hierarchy without the account directory.
If you don't have the same directory structure, maybe it makes more sense to try the option 2. It should allow more customization to match your structure (with some code tweaks...)
I have an account folder, below of it are Archive, Bulk. But maildirs-extension seem to have trouble with folders third level folders account/Archive/2014 ....
Ouch! Sorry, I read that wrong. Maybe I got confused because I didn't see the account folder in your output. Anyway, that 3rd level could be the problem. I'll try to test that ASAP.
Do you have cur
, new
and tmp
directories inside Archiv/
?
Something like this?
Archiv/
__cur/
__new/
__tmp/
__2014 Doctoral Retreat/
__2014 LK Oberstdorf/
__...
Well, let me try to explain what's happening here...
This extension adds a custom entry for the parent to query the submaildirs. So in your case + Archiv (0/147)
shows the unread and total counts of all the stuff inside Archiv
and you can enter to see all the mails (incl. submaildirs). The thing is that if you have cur
, new
and tmp
inside Archiv
that makes it a maildir too. So it conflicts with the virtual query. In that case, you have one entry | Archiv (0/0)
that represents the maildir, and another one with the virtual query that represents the submaildirs info + Archiv (0/147)
. If you move cur
, new
and tmp
in a directory inside Archiv
, for example in: Archiv/current/
the extension won't show the "duplicate" entry.
If you want a different behaviour, like for example to keep cur
, new
and tmp
inside Archiv/
and make + Archiv
show the info about that maildir (losing the virtual query functionality for the parent) and its submaildirs, well... that's currently not supported. But I can do this changes if you're interested.
I hope this explanation helped somehow.
@floli I just pushed an attempt to fix this in issue-15
branch.
(NOTE: it should work without the account directory too!)
Try with the following setting:
(setq mu4e-maildirs-extension-fake-maildir-separator "\\.")
Set this to prevent extra newlines if you don't use the account directory:
(setq mu4e-maildirs-extension-action-text "\t* [u]pdate index & cache\n\n")
(setq mu4e-maildirs-extension-before-insert-maildir-hook nil)
Let me know if this works for you!
Great! It looks like that now:
+ 2015 Ferienakademie (0/35)
+ Ablage (0/15)
+ Archiv (0/0)
| 2014 Doctoral Retreat (0/17)
| 2014 LK Oberstdorf (0/12)
| 2015 Coupled Problems (0/38)
| 2015 SIAM CSE (0/47)
| 2015 USNCCM (0/33)
+ Bulk (2/856)
| GitHub (1/102)
| Pubs (3/100)
+ Drafts (0/0)
+ ExaFSA (0/391)
| Bulk (0/404)
+ HPC Systeme (0/15)
+ INBOX (3/884)
+ Konferenzen (0/8)
+ Lehre (0/89)
| ILIAS (0/127)
+ Promotion (0/15)
+ Publikationssystem (0/29)
+ Scans (0/53)
+ Sent (0/802)
+ SGS (0/165)
+ SPPEXA (0/39)
+ Trash (0/417)
And that's almost like I want it to have!
I haven't set the mu4e-maildirs-extension-fake-maildir-separator
because I was able to configure offlineimap to use / as seperator, which makes more sense to me, too.
The mu4e-maildirs-extension-before-insert-maildir-hook
is run before inserting a maildir and is responsible to put a newline (mu4e-maildirs-extension-insert-newline-if-top-maildir
)? I don't really understand how that function is needed, isn't it done in the propertize-handler? I was able to achieve almost my desired formatting (besides the maildirs that contain submaildirs appearing twice) by using
(defun my-mu4e-maildirs-extension-propertize-handler (item)
(propertize (format "%s\t%s%s %s (%s/%s)\n"
(if (equal (plist-get item :level) 0) "" "")
[...]
and (setq mu4e-maildirs-extension-action-text "\t* [u]pdate index & cache\n\n")
based on the master branch. What about a setting mu4e-show-parent-maildirs-seperately
? With t is the current behavior of showing Archive and Archive as a parent with summarized read counts. When nil it shows just Archive as parent without summarizing the children. Or another property like is-childless-parent
which indicates if this item is a maildir with children but is the one that is rendered without children (the one I don't want to have)? Yeah, the name could use some improvement. The propertize-handler could then return nil to indicate that this item is not to rendered.
Eventually I will set (setq mu4e-maildirs-extension-action-text nil)
since, if I read the code correctly when updating mu4e index (U) maildirs-extension is also updated?
A thing that still could be improved imho is the handling of special directories like INBOX, Sent, Drafts, Trash. But I got no idea how a generalized configuration for that could look like.
Sorry about too much ideas... I really love it when you can interact with the authors, that's what I love about open source. My lisp knowledge is still negligible, but I try to learn. :-)
The output looks ok to me. What else do you miss?
The /
separator makes more sense to me too, but I think a lot of people use offlineimap with mu4e... so it's not a bad idea to support it :-)
I think its better to have hooks in general instead of having to redefine functions. So I moved that part into a hook (and the propertize function changed). But you can still disable the hook and redefine whatever you want in propertize. The mu4e-maildirs-extension-insert-newline-if-top-maildir
just checks the level and insert a newline before inserting the propertized text. So if you don't want the extra newline you can remove the hook and... done. The issue-15
branch have this little changes, but still not documented in the README.
About the counts... I think it's better that the default behaviour of mu4e-maildirs-extension
is to try to follow the directory structure. So if you have a parent maildir that have cur
,new
,tmp
... it will show that info in the node counts instead. But I do feel like, overall, I should need to rethink the way the config is customized. The propertized func is a bit too much... and some variables are confusing.
What's special about Inbox
, Sent
, Drafts
, Trash
? Can you explain a bit more what do you feel needs to be improved?
Feel free to open new issues or comment. I like to discus things! ^_^
Ah, I forgot to say that I'll merge this into master once I updated the docs and tested a bit more to see if anything breaks.
About the counts... I think it's better that the default behaviour of mu4e-maildirs-extension is to try to follow the directory structure. So if you have a parent maildir that have cur,new,tmp... it will show that info in the node counts instead.
So I understand you changed the bevaviour regarding multiple maildirs (my Archive dir) only temporarily in the issue-15 branch and will not merge them back to master? I think that's fine for me.
I think, as soon as you merge back this issue can be closed. Regarding special treatment of maildirs INBOX
et.al. I will open another issue.
Yes, ATM the changes are only in issue-15
branch but, as I said, I do plan to merge into master :-)
But if you want to use them now you need to manually install the version from issue-15
branch (no MELPA update until I merge into master, sorry!).
@floli I merged this changes (and a few more!) into master. It's already on MELPA (but I'll wait a bit before pushing to stable).
I'm closing this. Thank you for reporting and feel free to open new issues! :-)
My
~/Mail
looks like that:Therefore I have no multiple accounts, but a folder hierarchy , seperated by ".". It would be great if maildirs-extension would reflect this structure and indent each folder according to its nesting level.