Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd support for thread folding in mu4e-headers #783
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Feb 1, 2016
Contributor
I use it with
(define-key 'mu4e-headers-mode-map (kbd "TAB") 'mu4e-headers-toggle-thread-folding)TAB folds the current thread (even if point is not in the root message).
C-u TAB folds the subthread, i.e., all messages bellow the message at point.
TAB on a folded thread/subthread unfolds it.
Works with nested foldings as well, e.g., folding a subthread and then the whole thread.
|
I use it with (define-key 'mu4e-headers-mode-map (kbd "TAB") 'mu4e-headers-toggle-thread-folding)
Works with nested foldings as well, e.g., folding a subthread and then the whole thread. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
djcb
Feb 1, 2016
Owner
Oh, nice work! Some minor issue - seems tabbing takes the point to the next line; would be nice if type tab twice would return to the starting situation.
Another thing -- would it be hard to allow for buffer-wide operation, ie. collapse / uncollapse all threads? Perhaps with mu4e-headers-for-each?
|
Oh, nice work! Some minor issue - seems tabbing takes the point to the next line; would be nice if type tab twice would return to the starting situation. Another thing -- would it be hard to allow for buffer-wide operation, ie. collapse / uncollapse all threads? Perhaps with |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Feb 1, 2016
Contributor
seems tabbing takes the point to the next line
Yes, that was on purpose. I was thinking that since one wants to fold a thread probably he is not interested in it and one would like to move to the next thread. I was inspired by the way we mark threads.
would be nice if type tab twice would return to the starting situation.
That makes sense as well.
Another thing -- would it be hard to allow for buffer-wide operation, ie. collapse / uncollapse all threads? Perhaps with mu4e-headers-for-each?
If it is guaranteed that all messages belonging to the same thread are traversed one after another with mu4e-headers-for-each, then it should be easy.
Actually, this PR should be the start for more advanced features. For instance:
- Start view with all threads folded
- Add the number of unread messages in the string replacing the overlay (currently set to
"..."). - Mark folded threads with the face (and maybe flags) of any unread messages. This way one can see which folded threads have unread messages.
- "Arbitrary folding along the lines of gmail where previously read messages in a thread are folded automatically" as per @seanfarley.
The last two seem a long shot, but if you want I could implement the first two in this PR, or create new ones after this one gets merged upstream.
NOTE: I have found a small issue. If you press the down arrow instead of 'n' to get to a message that is not threaded (has no replies) and press tab then the cursor moves to the end of the previous line, but the correct line stays highlighted. I don't know why this happens, if you have any clue, please enlighten me :)
Yes, that was on purpose. I was thinking that since one wants to fold a thread probably he is not interested in it and one would like to move to the next thread. I was inspired by the way we mark threads.
That makes sense as well.
If it is guaranteed that all messages belonging to the same thread are traversed one after another with Actually, this PR should be the start for more advanced features. For instance:
The last two seem a long shot, but if you want I could implement the first two in this PR, or create new ones after this one gets merged upstream. NOTE: I have found a small issue. If you press the down arrow instead of 'n' to get to a message that is not threaded (has no replies) and press tab then the cursor moves to the end of the previous line, but the correct line stays highlighted. I don't know why this happens, if you have any clue, please enlighten me :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
djcb
Feb 1, 2016
Owner
Cool!
For the first item -- I think I'd prefer to get us to back
to starting position, just like e.g. org-mode does. We could have a
different function (perhaps bound to ) do the tab-and-next,
which can be useful as well. What do you think?
For the other items - indeed, mu4e-headers-for-each works in
headers-order, so that should work fine. Perhaps easiest for now would
be to do any collapsing into some kind of hook after all headers are
listed.
And agreed, let's look at the more complicated ones after the simpler ones are
there.
Anyway, with the tab-change, I think we can take the PR, and then work on
the rest. Nice things!
|
Cool! For the first item -- I think I'd prefer to get us to back For the other items - indeed, mu4e-headers-for-each works in And agreed, let's look at the more complicated ones after the simpler ones are Anyway, with the tab-change, I think we can take the PR, and then work on |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Oh, and I'll take a look at that small issue mentioned. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Feb 1, 2016
Contributor
The issue seems to disappear when I use save-excursion, which I will from now on. As a result you can ignore it, it won't exist in the next push ;)
|
The issue seems to disappear when I use |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Feb 2, 2016
Contributor
The function now takes two arguments, one for subthread folding and another for moving to the next thread after folding.
I also implemented the message counting. When folded, it will print +N where N is the number of messages in the folded thread/subthread. It also counts unread messages and displays them next to the total count like +N(M).
Ignore my previous comment about the issue, it looks like I can't always rely on save-excursion. The problem is with folding a thread while in it (not at its first message). In this case I have to move the cursor to the first message in the thread. So the glitch is still here, it is weird though that it only appears when moving down with the arrow key and then folding while on the first message of a thread.
I also had to play around with the position of the cursor for the overlays. Leaving it to the end-of-line results in the point appearing next to the display string, so I move it by -1. The above misbehavior might also relate to this.
Another bug/feature I observe is that when folding nested folds the display results in something like +7(3) +4(1) +2(1) where each +N(M) is the number of messages (and unread messages) in each folding level, from outermost to innermost.
|
The function now takes two arguments, one for subthread folding and another for moving to the next thread after folding. I also implemented the message counting. When folded, it will print Ignore my previous comment about the issue, it looks like I can't always rely on I also had to play around with the position of the cursor for the overlays. Leaving it to the Another bug/feature I observe is that when folding nested folds the display results in something like |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Feb 2, 2016
Contributor
We should probably make the display string customizable at some point.
|
We should probably make the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
djcb
Feb 3, 2016
Owner
Cool stuff, @zakkak! If you can fix those little things (hopefully easy to fix!), I'll merge this. I think it would be quite an improvement for mu4e!
|
Cool stuff, @zakkak! If you can fix those little things (hopefully easy to fix!), I'll merge this. I think it would be quite an improvement for mu4e! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Feb 3, 2016
Contributor
I think I will need some help to fix them. I am not very familiar with moving the point around.
Does mu4e introduce any invisible stuff at the beginning or the end of each line in the mu4e-headers view?
|
I think I will need some help to fix them. I am not very familiar with moving the point around. Does |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
djcb
Feb 4, 2016
Owner
Okay, I'll play around with it. And yes, there's a marker at the beginning of lines; see mu4e~headers-docid-pre
|
Okay, I'll play around with it. And yes, there's a marker at the beginning of lines; see mu4e~headers-docid-pre |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
djcb
Feb 5, 2016
Owner
I've pushed a zakkak/thread-folding branch here. Let's see if I have some hacking time this weekend...
As for #' vs ' - they are not the same, but I don't the difference matters much. But let's use the latter, it's simpler.
|
I've pushed a As for |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andersjohansson
Feb 16, 2016
Contributor
Regarding #' and ':
Use a sharp quote (#') when quoting function names. It's a good hint for the byte-compiler, which will warn you if the function is undefined. Some macros can also behave differently otherwise (like cl-labels).
https://github.com/bbatsov/emacs-lisp-style-guide
Don't ask me about what difference it really makes though...
|
Regarding
https://github.com/bbatsov/emacs-lisp-style-guide Don't ask me about what difference it really makes though... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
hexa00
Aug 12, 2016
Hi,
I've been using this branch for a few months and really like it :)
However I really wish I could fold/unfold all threads, has anyone figured this out already ?
I tried the naive way calling like :
(defun mu4e-headers-fold-all ()
"Folds all threads"
(interactive)
(mu4e-headers-for-each 'mu4e-headers-toggle-thread-folding))
But that was too naive it seems...
Thanks,
hexa00
commented
Aug 12, 2016
|
Hi, However I really wish I could fold/unfold all threads, has anyone figured this out already ? I tried the naive way calling like : (defun mu4e-headers-fold-all () But that was too naive it seems... Thanks, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dakrone
Sep 27, 2016
What's the word on this, is it something that's likely to be merged into mu4e, or something users should use a custom build to add support for?
dakrone
commented
Sep 27, 2016
|
What's the word on this, is it something that's likely to be merged into mu4e, or something users should use a custom build to add support for? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Sep 27, 2016
Contributor
It is still far from perfect. Since I am pretty busy the last few months I don't know when and if I will manage to get it in a good shape to be merged upstream.
Any contributions are welcome.
|
It is still far from perfect. Since I am pretty busy the last few months I don't know when and if I will manage to get it in a good shape to be merged upstream. Any contributions are welcome. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Dec 30, 2016
Contributor
Bump. I finally got some time to take a look at the code and fix a few things.
So, folding seems to work better now.
Known issues
Marking folded threads:
- applies mark only to visible message (maybe this is OK as is) and
- breaks visualization by hiding the message and showing only the overlay display (not OK).
|
Bump. I finally got some time to take a look at the code and fix a few things. So, folding seems to work better now. Known issuesMarking folded threads:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
hexa00
Jan 9, 2017
Hi,
Thanks for working on this !
I just updated and I notice this small issue when folding I get:
Subject +8(8)h
Notice the 'h" , this can be any char, most likely tied to some text in the area....
Also, not sure I understand known issue #2.. ?
hexa00
commented
Jan 9, 2017
|
Hi, I just updated and I notice this small issue when folding I get: Notice the 'h" , this can be any char, most likely tied to some text in the area.... Also, not sure I understand known issue #2.. ? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Jan 9, 2017
Contributor
Hi,
I can't reproduce the Subject +8(8)h issue.
Regarding the second Known Issue, it refers to applying some mark at a folded thread. After applying the mark the whole line disappears for me and I am only left with the counts, e.g., Date | From | Subject +8(8) becomes +8(8).
|
Hi, I can't reproduce the Regarding the second Known Issue, it refers to applying some mark at a folded thread. After applying the mark the whole line disappears for me and I am only left with the counts, e.g., |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
hexa00
Jan 9, 2017
You mean like doing on a folded thread ?
That works fine here, only issue is that the cursor goes to the end of the line...
hexa00
commented
Jan 9, 2017
|
You mean like doing on a folded thread ? That works fine here, only issue is that the cursor goes to the end of the line... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
hexa00
Jan 9, 2017
Oops I mean doing "insert" on a folded thread,, I used '<' and '>' and github just removed the tag...
hexa00
commented
Jan 9, 2017
|
Oops I mean doing "insert" on a folded thread,, I used '<' and '>' and github just removed the tag... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Jan 9, 2017
Contributor
Hmmm, <insert> seems to not trigger the issue, try marking a folded thread as read and apply the action.
|
Hmmm, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Jan 9, 2017
Contributor
More accurately if you choose to apply a mark after <insert> the problem appears again.
|
More accurately if you choose to apply a mark after |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
hexa00
Jan 9, 2017
OK I see, I can reproduce now, thanks for the explaination. (Note that I get +8(8)h )
On another note the only big missing features for me would be to:
- Have some way to fold all threads.
- Keep the folded thread folded when mu refreshes...
Have you considered those ?
Thanks,
hexa00
commented
Jan 9, 2017
|
OK I see, I can reproduce now, thanks for the explaination. (Note that I get +8(8)h ) On another note the only big missing features for me would be to:
Have you considered those ? Thanks, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Jan 9, 2017
Contributor
Well those make sense and would be great to have.
One step at a time :)
|
Well those make sense and would be great to have. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
hexa00
commented
Jan 9, 2017
|
hehe OK :) Just making sure I haven't missed it. Thanks again! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Jan 25, 2017
Contributor
@djcb could you please have a look in to this and let me know of any comments/directions?
|
@djcb could you please have a look in to this and let me know of any comments/directions? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
djcb
Jan 25, 2017
Owner
He @zakkak, nice to see this! I like the functionality; the implementation is a bit complicated (probably necessarily so). Anyway, are you happy with how it works? Ie., does it all work as expected?
|
He @zakkak, nice to see this! I like the functionality; the implementation is a bit complicated (probably necessarily so). Anyway, are you happy with how it works? Ie., does it all work as expected? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Jan 26, 2017
Contributor
Other than not supporting marking folded threads (#783 (comment)), I am pretty happy about it and use it on a daily base.
|
Other than not supporting marking folded threads (#783 (comment)), I am pretty happy about it and use it on a daily base. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
felipeochoa
Mar 16, 2017
I've refactored this a bit to split out the complexity into different functions[1]. I've also added a mu4e-headers-fold-all that I like adding to mu4e-headers-found-hook. There's also now an option to override the "folded slug" formatting under mu4e-headers-folding-slug-function.
There are a couple of small bugs in the folding:
- Pressing
non a header with a folded thread moves point to EOL instead of down to the next header. I think the fix is inmu4e~headers-move, whereforward-lineneeds to becomeforward-visible-line, but I'm not sure. - Marking a header while point is on the overlay breaks the folding. There are two solutions here:
- The quick one: This happens because
mu4e-mark-at-pointcalls an unqualifiedremove-overlays, splitting the folding overlay. If instead these overlays defined some property likemu4e-marking-overlay, the call toremove-overlayscould filter these out and avoid this problem. - The complete one: We should probably keep a hash of folded messages. That way we can forbid marking of folded headers with a check in
mu4e-mark-at-pointormu4e~headers-mark. This hash could also be used re-instate folding after an index update
- The quick one: This happens because
Sorry I don't have time to make this into a PR and fix these bugs, but hopefully this pushes the ball forward a bit.
[1] https://gist.github.com/felipeochoa/614308ac9d2c671a5830eb7847985202
felipeochoa
commented
Mar 16, 2017
|
I've refactored this a bit to split out the complexity into different functions[1]. I've also added a There are a couple of small bugs in the folding:
Sorry I don't have time to make this into a PR and fix these bugs, but hopefully this pushes the ball forward a bit. [1] https://gist.github.com/felipeochoa/614308ac9d2c671a5830eb7847985202 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Mar 16, 2017
Contributor
It sure does. Thanks for your contributions.
I will try to get your changes on my branch, but it would be better if you could create a PR.
In the meantime if anyone else is willing to do the PR, it will be much appreciated.
|
It sure does. Thanks for your contributions. I will try to get your changes on my branch, but it would be better if you could create a PR. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sebhahn
commented
Aug 7, 2017
|
Is this feature merged anytime soon? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Sep 6, 2017
Contributor
Probably not, it is not stable yet.
Unfortunately I don't have much time to work on it so if anyone is willing to take it over, it would be great.
|
Probably not, it is not stable yet. Unfortunately I don't have much time to work on it so if anyone is willing to take it over, it would be great. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
stefanv
commented
Sep 7, 2017
|
@zakkak Can you expand a bit on what needs to be done? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zakkak
Sep 26, 2017
Contributor
There are the issues mentioned here regarding marking and applying actions on folded threads.
There is also this patch that needs to be merged and it also lists some more issues.
|
There are the issues mentioned here regarding marking and applying actions on folded threads. |
djcb
referenced this pull request
May 14, 2018
Open
mu4e: Single-buffer view of thread, a.k.a. conversation view #1239
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
titaniumbones
Oct 1, 2018
Contributor
I'm not in a position to track down and fix these bugs but just want to add a word of encouragement to whomever might be able to od it -- I've just loaded @felipeochoa 's gist version and while I'm sure at some point the bugs that @zakkak mentions will become frustrating, already I notice a dramatic improvement in usage of mu4e. I would love to see this merged to master so everyone can take advantage of it.
|
I'm not in a position to track down and fix these bugs but just want to add a word of encouragement to whomever might be able to od it -- I've just loaded @felipeochoa 's gist version and while I'm sure at some point the bugs that @zakkak mentions will become frustrating, already I notice a dramatic improvement in usage of mu4e. I would love to see this merged to master so everyone can take advantage of it. |
zakkak commentedFeb 1, 2016
Implementation for rfe #75
Add ability to fold/unfold threads.