How to have all threads folded when first displaying header buffer?

18 views
Skip to first unread message

Richard H Stanton

unread,
Apr 2, 2024, 7:02:52 PMApr 2
to mu-discuss
I'd like to fold all my threads automatically when i enter the header buffer. I've tried 

(add-hook 'mu4e-headers-mode-hook
          (lambda ()
            (mu4e-thread-fold-all)))

but it doesn't do what i want, even though manually running mu4e-thread-fold-all works fine.

What am I missing?

Thanks!

Joost Kremers

unread,
Apr 2, 2024, 7:32:45 PMApr 2
to 'Richard H Stanton' via mu-discuss
A mode hook is run when a mode is activated (and when it is deactivated, BTW),
which in the case of `mu4e-headers-mode` is (most likely) happens before the
buffer is actually filled. So you're calling `mu4e-thread-fold-all` before there
are any headers in the buffer. (I say "most likely", because I'm not actually familiar
with the relevant code, but it would make the most sense.)

I don't know if there's a way to do what you want. Ideally, there would be a
user option to control this, but I don't think there is.

Note, BTW that if you have a `lambda` with only one function, you can just use
the function itself:

(add-hook 'mu4e-headers-mode-hook #'mu4e-thread-fold-all)




--
Joost Kremers
Life has its moments

Tassilo Horn

unread,
Apr 3, 2024, 3:44:02 AMApr 3
to mu-di...@googlegroups.com
Joost Kremers <joostk...@fastmail.fm> writes:

> I don't know if there's a way to do what you want. Ideally, there
> would be a user option to control this, but I don't think there is.

I think

(setq-default mu4e-thread--fold-status t)

should do the trick (don't ask me why that is a "private" variable).

Bye,
Tassilo

Richard H Stanton

unread,
Apr 3, 2024, 4:06:23 AMApr 3
to mu-discuss
Thanks for the suggestion, but this doesn't seem to do what I'm looking for, I'm afraid.

Joost Kremers

unread,
Apr 3, 2024, 4:11:38 AMApr 3
to Tassilo Horn, mu-di...@googlegroups.com
Well, a quick look at the code suggests that `mu4e-thread--fold-status` is used
to keep track of the current fold status: its value is changed when you fold or
unfold all threads. That wouldn't be appropriate for a user option.

Just noticed: (info "(mu4e) Folding threads") says this:

```
If you want to automatically fold all threads after a query, you can
use a hook:
(add-hook 'mu4e-thread-mode-hook #'mu4e-thread-fold-apply-all)
```

@Richard, Perhaps that does what you're looking for?

Tassilo Horn

unread,
Apr 3, 2024, 4:18:33 AMApr 3
to mu-di...@googlegroups.com
"'Richard H Stanton' via mu-discuss" <mu-di...@googlegroups.com> writes:

Hi Richard,

> Thanks for the suggestion, but this doesn't seem to do what I'm
> looking for, I'm afraid.
>>
>> I think
>>
>> (setq-default mu4e-thread--fold-status t)
>>
>> should do the trick (don't ask me why that is a "private" variable).

Hm, I can assure you I've had

(setopt mu4e-thread--fold-status t)

in my config (which assumes Emacs 29.1 or never) which made threads
folded by default (with mu 1.12.x). I didn't like that behavior so
removed that line again but again, it worked for me two weeks ago.

There are also other variables wrt. folding, e.g., I had set

(setopt mu4e-thread-fold-single-children t)

so that threads with just one child were folded, too, which is a bit
senseless given that you only replace the real child with a folding line
so no space is saved.

Bye,
Tassilo

Richard H Stanton

unread,
Apr 3, 2024, 4:21:08 AMApr 3
to mu-discuss
Aha! It works if I use mu4e-thread-fold-all.

Thanks!

Richard H Stanton

unread,
Apr 3, 2024, 4:23:42 AMApr 3
to mu-discuss
That was supposed to be in reply to Joost's message above. In other words, this works for me:

(add-hook 'mu4e-thread-mode-hook #'mu4e-thread-fold-all)

Richard H Stanton

unread,
Apr 3, 2024, 9:39:26 AMApr 3
to mu-discuss
Odd. It definitely didn't work for me! Maybe it interacts with some of my other settings, but since this problem is now solved, I'm not sure we'll ever know...

Best,

Richard

Jerry Lee Daniel

unread,
May 7, 2024, 5:40:05 AMMay 7
to mu-discuss

Loans, Project and Digital Investment financing available up to $150m.
Have a Business Plan, Fundable Project and Collateral.

Contact: danielj...@gmail.com
Whatsapp: ‪+1 (918) 707‑0858
Reply all
Reply to author
Forward
0 new messages