Re: use script output as regex pattern in folder-fook

2008-07-28 Thread Michelle Konzack
Am 2008-07-25 11:46:10, schrieb David Champion:
 and generate your real muttrc programmatically: another way to do
 things like macros/variables and search paths, and you also get to
 automatically define hooks, lists, etc. based on the contents of your
 filesystem.  But once again this only executes at startup -- it doesn't
 update itself continuously.
 
 If you're ambitious enough you could set mutt up to reload much of its
 configuration every time you change folders, or something.  But I'm
 not sure how useful this really is for most people. :)

I have already done this, which mean, on  my  IBM  TP570  (P2/366/192MB)
mutt need arround 2 minutes to load, but then it hast the total power...

Maybe it is pervers, but it just works...

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


use script output as regex pattern in folder-fook

2008-07-25 Thread Steve S
Hi

I have a folder-hook acting on different folders:

folder-hook folder1|folder2|folder3 ...

I replaced this with

folder-hook script.sh| ...

and script.sh :

echo 'folder1|folder2|folder3'

Now, the pattern matches every folder, i.e. the hook acts on all folders, not
just folder1,2,3. Is there a way do actually see what Mutt gets if it executes
script.sh (there's nothing in .muttdebug0)? Or doesn't the script get executed
at all.

steve


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread Michael Kjorling
On 25 Jul 2008 14:06 +0200, by [EMAIL PROTECTED] (Steve S):
 I replaced this with
 
 folder-hook script.sh| ...
 
 and script.sh :
 
 echo 'folder1|folder2|folder3'

Maybe what you want is more along the lines of

folder-hook `script.sh` ...

-- 
Michael Kjörling .. [EMAIL PROTECTED] .. http://michael.kjorling.se
* . No bird soars too high if he soars with his own wings . *
* ENCRYPTED email preferred -- OpenPGP key ID: 0x 758F8749 BDE9ADA6 *
* ASCII Ribbon Campaign: Against HTML mail, proprietary attachments *



signature.asc
Description: Digital signature


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread Steve S
On Jul 25 12:44, Michael Kjorling wrote:
 On 25 Jul 2008 14:06 +0200, by [EMAIL PROTECTED] (Steve S):
  I replaced this with
  
  folder-hook script.sh| ...
  
  and script.sh :
  
  echo 'folder1|folder2|folder3'
 
 Maybe what you want is more along the lines of
 
 folder-hook `script.sh` ...
 

Yes, that was my initial attempt. It works if I use 

folder-hook `/path/to/script.sh` ...

I have tried

set my_muttdir=$HOME/.mutt
folder-hook `$my_muttdir/script.sh` ...

Here, Mutt doesn't seem to expand $my_muttdir before handing the command over
to the shell. Is there a trick to do that?

steve


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread David Champion
 folder-hook folder1|folder2|folder3 ...
 
 I replaced this with
 
 folder-hook script.sh| ...

This approach won't work.  Here's why, and a possible alternative.

The script.sh| notation for incorporating a script's output into your
muttrc only works where mutt knows that it's looking for a filename or
a format string.  Otherwise, script.sh| is just a literal string.
In your case, it's a regular expression listing a set of either-or
patterns, and one of these patterns is an empty string, which matches
everything since all strings contain an empty string as a subset.

As Michael said, you can use `script.sh` instead.  This should
work equally well for most purposes.  The only difference is that
script.sh|, when it works, executes the script each time that the
value is evaluated.  `script.sh` executes the script only once, at
the time that the muttrc is processed.

This makes script.sh| really useful only when used for set variables
that are evaluated multiple times.  Hooks are evaluated only once
anyway, so it wouldn't really be meaningful.

If you really need the same kind of dynamic meaning that script.sh|
provides over `script.sh`, you might be able to use a compound
folder-hook -- something like this:

folder-hook . 'folder-hook \`script.sh\` command...'

or perhaps:

# all other folder-hooks in folder-hooks.mutt
folder-hook . 'source folder-hooks.mutt'

These are untested, but its intention is that for each folder change,
mutt will interpret folder-hook `script.sh` command... again.  I'm
not sure that the second folder-hook would actually be applied to the
new (now current) folder, though.  It might be necessary to reopen the
folder to make the new folder-hook stick, and that's so unusable as to
make the whole approach worthless.

-- 
 -D.[EMAIL PROTECTED]NSITUniversity of Chicago


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread Steve S
On Jul 25 08:15, David Champion wrote:
  folder-hook folder1|folder2|folder3 ...
  
  I replaced this with
  
  folder-hook script.sh| ...
 
 This approach won't work.  Here's why, and a possible alternative.
 
 The script.sh| notation for incorporating a script's output into your
 muttrc only works where mutt knows that it's looking for a filename or
 a format string.  Otherwise, script.sh| is just a literal string.
 In your case, it's a regular expression listing a set of either-or
 patterns, and one of these patterns is an empty string, which matches
 everything since all strings contain an empty string as a subset.
 
 As Michael said, you can use `script.sh` instead.  This should
 work equally well for most purposes.  The only difference is that
 script.sh|, when it works, executes the script each time that the
 value is evaluated.  `script.sh` executes the script only once, at
 the time that the muttrc is processed.
 
 This makes script.sh| really useful only when used for set variables
 that are evaluated multiple times.  Hooks are evaluated only once
 anyway, so it wouldn't really be meaningful.

Thanks for the clarification. I use script.sh| in various set ... commands,
so I naively figured I could use it in a folder-hook too.

As I stated in the reply to Michael's message, I'd be happy if something like

set $my_path=/some/path
folder-hook `$my_path/script.sh` ...

would be possible. 

 If you really need the same kind of dynamic meaning that script.sh|
 provides over `script.sh` 
 [...]

No, not really. I substituted one for the other so I didn't even know there
was some dynamic to use :)

steve


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread Rocco Rutte

Hi,

* Steve S wrote:


I have tried



   set my_muttdir=$HOME/.mutt
   folder-hook `$my_muttdir/script.sh` ...



Here, Mutt doesn't seem to expand $my_muttdir before handing the command over
to the shell. Is there a trick to do that?


It doesn't seem so. At least for interactive shell-escape function it's 
documented that these variables aren't expanded... and I assume the same 
is true for backtick expansion.


Rocco


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread Steve S
On Jul 25 17:32, Rocco Rutte wrote:
 Hi,

 * Steve S wrote:

 I have tried

set my_muttdir=$HOME/.mutt
folder-hook `$my_muttdir/script.sh` ...

 Here, Mutt doesn't seem to expand $my_muttdir before handing the command over
 to the shell. Is there a trick to do that?

 It doesn't seem so. At least for interactive shell-escape function it's  
 documented that these variables aren't expanded... and I assume the same  
 is true for backtick expansion.


OK, then I'll set an env var MUTTDIR and do

folder-hook `$MUTTDIR/script.sh` ...

A more elegant solution could be a config var $configdir or $scriptdir for
people who 

- have more then one script laying around in ~/.mutt (or wherever) 
- don't want to put Mutt-specific scripts in a location on $PATH

My 0.02 $.

steve


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread Steve S
On Jul 25 10:36, David Champion wrote:
 set my_muttdir=$HOME/.mutt
 folder-hook `$my_muttdir/script.sh` ...
 
  Here, Mutt doesn't seem to expand $my_muttdir before handing the command 
  over
  to the shell. Is there a trick to do that?
 
  It doesn't seem so. At least for interactive shell-escape function it's  
  documented that these variables aren't expanded... and I assume the same  
  is true for backtick expansion.
 
 You can work around this by putting MUTTDIR in your shell environment
 before running mutt.
 
 sh$ export MUTTDIR=~/.mutt
   with
 folder-hook `$MUTTDIR/script.sh`
 

Hmm, how do you read my mind? :)

steve


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread David Champion
  You can work around this by putting MUTTDIR in your shell environment
  before running mutt.
 
 Hmm, how do you read my mind? :)

:)

Well, I actually do this for a few variables -- predating the $my_xyz
feature.  I should switch where I can though, so I can drop the setenv
patch.  (Lets me stuff things into the environment from inside mutt.)


 A more elegant solution could be a config var $configdir or $scriptdir for
 people who 
 
 - have more then one script laying around in ~/.mutt (or wherever) 
 - don't want to put Mutt-specific scripts in a location on $PATH

You also can do this in ~/.muttrc:

source ~/.mutt/muttrc.py|

and generate your real muttrc programmatically: another way to do
things like macros/variables and search paths, and you also get to
automatically define hooks, lists, etc. based on the contents of your
filesystem.  But once again this only executes at startup -- it doesn't
update itself continuously.

If you're ambitious enough you could set mutt up to reload much of its
configuration every time you change folders, or something.  But I'm
not sure how useful this really is for most people. :)

-- 
 -D.[EMAIL PROTECTED]NSITUniversity of Chicago


Re: use script output as regex pattern in folder-fook

2008-07-25 Thread Steve S
On Jul 25 11:46, David Champion wrote:
  A more elegant solution could be a config var $configdir or $scriptdir for
  people who 
  
  - have more then one script laying around in ~/.mutt (or wherever) 
  - don't want to put Mutt-specific scripts in a location on $PATH
 
 You also can do this in ~/.muttrc:
 
 source ~/.mutt/muttrc.py|
 
 and generate your real muttrc programmatically: another way to do
 things like macros/variables and search paths, and you also get to
 automatically define hooks, lists, etc. based on the contents of your
 filesystem.  
 But once again this only executes at startup -- it doesn't
 update itself continuously.
 
 If you're ambitious enough you could set mutt up to reload much of its
 configuration every time you change folders, or something.  But I'm
 not sure how useful this really is for most people. :)

Wow, one could write a research paper on Mutt configuration :) The number of my
scripts and vars is greater than one but so far still manageable by hand and 
some
backtick-magic here and there. Thanks!

steve