sidebar inconsistencies or misunderstandings

2022-12-06 Thread Andy Spiegl
Playing around with the sidebar I came up with a few inconsistencies or
most likely misunderstandings.  Maybe someone could enlighten me please?

* The sidebar really cannot see a difference between NEW and OLD mails?
  So, %N shows the sum of NEW and OLD mails?
  But then, how is the value %n calculated? (N if mailbox has new mail, blank 
otherwise)
  And buffy-list also knows which mailboxes have new mail.  Well, but not how 
many.

* I tried "unset mail_check_recent" and "set mark_old" as the manual
  suggests in section 3.164 but I don't see a difference.

* %n is not updated when the mailbox is modified externally.
  check-stats or check-new do not update it either.
  But: Turning the sidebar off and on sometimes(!) does update it.
  (mail_check_stats is set and mail_check_stats_interval=30)

* sidebar-next-new does not jump to the next mailbox with new mail
  (according to %n) but only skips mailboxes with no unread (%N==0) mails.

And finally a curious question about the mailbox browser:
Is there a function/method "next-new" (like "sidebar-next-new") to jump
to the next mailbox with new mail?

Thanks so much,
 Andy

-- 
 If you have good memory you can forget the rest.


Re: Muttlisp question

2022-12-06 Thread Andy Spiegl
> Oh, I meant less efficient because the evaluation is done every time the key
> is pressed when using the macro.  Plus it's a macro executing a
>  which is evaluating MuttLisp.

Oh, of course!  You are right.
What was I thinking?  Maybe I should stop tweaking my mutt config and go to 
bed? :-)

Thanks,
 Andy

-- 
 There is no kind of dishonesty into which otherwise good people more easily and
 frequently fall than that of defrauding the government.
   (Benjamin Franklin)


Re: Muttlisp question

2022-12-06 Thread Kevin J. McCarthy

On Tue, Dec 06, 2022 at 10:08:04PM +0100, Andy Spiegl wrote:

Well, you could try putting the keybindings such as

Sure, but weren't we talking about efficency, i.e. without Muttlisp?  :-)


Oh, I meant less efficient because the evaluation is done every time the 
key is pressed when using the macro.  Plus it's a macro executing a 
 which is evaluating MuttLisp.


The bind cost is paid a single time, when toggling the sidebar, but not 
when pressing the key.


--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA


signature.asc
Description: PGP signature


Re: Muttlisp question

2022-12-06 Thread Andy Spiegl
> Sorry I wasn't clear enough.
Now I understood it.  Thank you very much!

> Well, you could try putting the keybindings such as
Sure, but weren't we talking about efficency, i.e. without Muttlisp?  :-)

Thanks,
 Andy

-- 
 The brain is a wonderful organ; it starts working the moment you get up
 in the morning, and does not stop until you get to work.


Re: Muttlisp question

2022-12-06 Thread Kevin J. McCarthy

On Tue, Dec 06, 2022 at 08:47:27PM +0100, Andy Spiegl wrote:

The muttlisp can't be inside quotes, so I removed the outer single
quotes.

Is this only true for "bind" lines?
Because in the macro the muttlisp code is inside quotes:

macro index j 'run (if (equal $sidebar_visible "yes")  \
 "exec sidebar-next" \
 "exec next-undeleted")'


Sorry I wasn't clear enough.  When a command is read and executed by the 
muttrc parser, a MuttLisp argument can't be surrounded by quotes.  That 
is, the muttrc parser won't look inside a quoted argument for MuttLisp.


The above macro, when initially read in from your .muttrc, won't look 
for MuttLisp in the third argument.


However, when the macro is executed, by pressing 'j', it starts a 
command prompt, using .  The line:


  run (if (equal $sidebar_visible "yes") "exec sidebar-next" "exec 
next-undeleted")

is then read and executed by the muttrc parser when  is processed 
at the end of the macro.  At that time, it will evaluate the first 
argument to the run command as MuttLisp because it is not surrounded by 
a quote.


Note that surrounding the macro with single quotes prevents the 
evaulation of $sidebar_visible when the muttrc is evaluated.  So the 
MuttLisp above will look at the value of $sidebar_visible when it is 
executed.



It's a bit less efficient, so if that's a concern, you could just use a
macro to toggle $sidebar_visible and at the same time source a file with the
special "sidebar toggling" bind commands.

Good idea but how would I set the key bindings depending on the visibility
state of the sidebar?  I'd need some kind of if-then-else because the
toggle macro doesn't "know" the state.  Or can you think of a smart method
to do that?


Well, you could try putting the keybindings such as

bind index j (if (equal $sidebar_visible "yes")  \
 'sidebar-next'  \
 'next-undeleted')

bind index k (if (equal $sidebar_visible "yes")  \
 'sidebar-prev  \
 'previous-undeleted')

[...]

in a file '~/.mutt/sidebar-bindings' and then

macro index ^ "\
toggle sidebar_visible\
source ~/.mutt/sidebar-bindings\
"

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA


signature.asc
Description: PGP signature


Re: Muttlisp question

2022-12-06 Thread Andy Spiegl
Kevin, thanks a lot!
This was exactly what I was looking for.

> The muttlisp can't be inside quotes, so I removed the outer single
> quotes.
Is this only true for "bind" lines?
Because in the macro the muttlisp code is inside quotes:
> macro index j 'run (if (equal $sidebar_visible "yes")  \
>  "exec sidebar-next" \
>  "exec next-undeleted")'

> It's a bit less efficient, so if that's a concern, you could just use a
> macro to toggle $sidebar_visible and at the same time source a file with the
> special "sidebar toggling" bind commands.
Good idea but how would I set the key bindings depending on the visibility
state of the sidebar?  I'd need some kind of if-then-else because the
toggle macro doesn't "know" the state.  Or can you think of a smart method
to do that?

My first guess would have been like this:
macro index ^ "\
toggle sidebar_visible\
bind index,pager j next-undeleted\< this line 
depends
" \
"hide mutt sidebar and set key bindings"

Thanks,
 Andy

-- 
 If it's true that we are here to help others, then what
 exactly are the OTHERS here for?