Re: Deleting github commit messages: folder-hook/regex problem

2022-09-28 Thread Francesco Ariis
Kevin,

Il 28 settembre 2022 alle 10:05 Kevin J. McCarthy ha scritto:
> Or alternatively, add an escaped single quote around the second argument:
>   folder-hook fa-ml 'push '\''~b"^@[a-zA-Z0-9_]+ pushed 
> [0-9]+ commits?.$"!~F'\'

This worked, thanks.

“Parse time”/“run time” distinction is still a tricky bit of mutt to me.
—F


Re: Deleting github commit messages: folder-hook/regex problem

2022-09-27 Thread Kevin J. McCarthy

On Tue, Sep 27, 2022 at 04:13:21PM +0200, Francesco Ariis wrote:

2. wrote this folder-hook in my muttrc:
folder-hook fa-ml 'push ~b"^@[a-zA-Z0-9_]+ pushed [0-9]+ 
commits?.$"!~F'


The third argument above, "push", will be evaluated twice by the 
muttrc parser.


The first time, when reading the line out of your muttrc file.  The 
parser will extract three arguments:

  folder-hook
  fa-ml
  push ~b"^@[a-zA-Z0-9_]+ pushed [0-9]+ commits?.$"!~F

Note when the third argument was parsed, the single quotes are not 
included in the result - they are used to evaluate the argument in 
"single quotes" mode during parsing.


Mutt uses this to create a folder hook, matching against 'fa-ml', and 
will parse and run the third argument when the hook runs.


So, when the folder hook actually runs, the muttrc parser will extract
two arguments:
  push
  ~b^@[a-zA-Z0-9_]+ pushed [0-9]+ commits?.$!~F

Note the double quotes are not included in the result, they (again) are
used to evaluate their contents in "double quotes" mode during parsing.

You could try putting a backslash in front of each double quote:
  folder-hook fa-ml 'push ~b\"^@[a-zA-Z0-9_]+ pushed [0-9]+ 
commits?.$\"!~F'

Or alternatively, add an escaped single quote around the second argument:
  folder-hook fa-ml 'push '\''~b"^@[a-zA-Z0-9_]+ pushed [0-9]+ 
commits?.$"!~F'\'

When this line is first parsed, it will be the three arguments:
  folder-hook
  fa-ml
  push '~b"^@[a-zA-Z0-9_]+ pushed [0-9]+ commits?.$"!~F'

And when the hook is run, it will parse two arguments:
  push
  ~b"^@[a-zA-Z0-9_]+ pushed [0-9]+ commits?.$"!~F

I haven't actually tested anything here (so there may be some typos), 
but hopefully that will get you going in the right direction to debug 
things.


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


signature.asc
Description: PGP signature