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 <delete-pattern>~b"^@[a-zA-Z0-9_]+ pushed [0-9]+ 
commits?.$"!~F<enter>'

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 <delete-pattern>~b"^@[a-zA-Z0-9_]+ pushed [0-9]+ commits?.$"!~F<enter>

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
  <delete-pattern>~b^@[a-zA-Z0-9_]+ pushed [0-9]+ commits?.$!~F<enter>

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 <delete-pattern>~b\"^@[a-zA-Z0-9_]+ pushed [0-9]+ 
commits?.$\"!~F<enter>'

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

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

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

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

Attachment: signature.asc
Description: PGP signature

Reply via email to