<<< Date Index >>>     <<< Thread Index >>>

Re: hook \\.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday, October 12 at 05:53 PM, quoth Joseph:
>I'm reading mutt manual and it has an example:
>
>save-hook me@(turing\\.)?cs\\.hmc\\.edu$ +elkins
>save-hook aol\\.com$ +spam
>
>Why there is a "\\."?
>I know singe backslash "\" turn off special meaning for "." 
>double backslash would indicate that it is a "\" character. 

It's because of mutt's sometimes inscrutable escaping rules. When mutt 
is reading something that isn't quoted, it strips off a level of 
escapes. So the following two lines are equivalent:

     save-hook me@turing\\.cs\\.hmc\\.edu +elkins
     save-hook 'me@turing\.cs\.hmc\.edu'  +elkins

The following two lines are ALSO equivalent:

     save-hook .  foo
     save-hook \. foo

The way mutt's parser works, first it extracts strings to match the 
pattern:

     save-hook string1 string2

Then, string1 is saved as the regular expression that triggers the 
hook, and string2 is saved as the command to run. Mutt un-escapes 
things when interpreting the rc file to extract string1, but the 
backslash has to survive and be present in the regular expression. 
Thus, unless you quote it, you have to use two backslashes.

Consider that you can also use octal escapes:

     save-hook me@\146 +elkins

When mutt interprets that, it will store string1 as "me@f". That way 
you can encode unusual characters into the muttrc (such as your $from 
or $realname) even if your muttrc can only be in us-ascii (for 
whatever reason).

~Kyle
- -- 
I think we ought always to entertain our opinions with some measure of 
doubt. I shouldn't wish people dogmatically to believe any philosophy, 
not even mine.
                                                    -- Bertrand Russell
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iD8DBQFHEBVABkIOoMqOI14RAqBHAKDTEF8bmiUD4QF/fn6964BmsDT9kwCgnf5y
CGsGDAnpFlAGZyz8hPTxLro=
=VQok
-----END PGP SIGNATURE-----