reference the folder name in a folder-hook push command

2017-12-25 Thread Yubin Ruan
Hi,

I have a folder hook like this:

folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'

where I would like to create a file "/tmp/somebox-touched" when I select and
enter a mailbox. As you can see, \1 here should represent the name of the mbox
(as in many Regex). Is there a way to do this so that I do not have to write
rules for all the mbox one by one?

(actually I just want to pass as argument the name of a mbox to some external
shell command)


Regards,
Yubin


Re: reference the folder name in a folder-hook push command

2017-12-26 Thread Arkadiusz Drabczyk
On Tue, Dec 26, 2017 at 06:36:20AM +0800, Yubin Ruan wrote:
> Hi,
> 
> I have a folder hook like this:
> 
> folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'
> 
> where I would like to create a file "/tmp/somebox-touched" when I select and
> enter a mailbox. As you can see, \1 here should represent the name of the mbox
> (as in many Regex). Is there a way to do this so that I do not have to write
> rules for all the mbox one by one?

Like that:

folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
set record=$my_oldrecord'
folder-hook . 'push "!touch /tmp/${my_folder}-touched\n"'

-- 
Arkadiusz Drabczyk 


Re: reference the folder name in a folder-hook push command

2017-12-26 Thread Yubin Ruan
On Tue, Dec 26, 2017 at 04:23:50PM +0100, Arkadiusz Drabczyk wrote:
> On Tue, Dec 26, 2017 at 06:36:20AM +0800, Yubin Ruan wrote:
> > Hi,
> > 
> > I have a folder hook like this:
> > 
> > folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'
> > 
> > where I would like to create a file "/tmp/somebox-touched" when I select and
> > enter a mailbox. As you can see, \1 here should represent the name of the 
> > mbox
> > (as in many Regex). Is there a way to do this so that I do not have to write
> > rules for all the mbox one by one?
> 
> Like that:
> 
> folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
> set record=$my_oldrecord'
> folder-hook . 'push "!touch /tmp/${my_folder}-touched\n"'

Thanks! I didn't know that ^ represent the current folder name. A greate trick
;-)

Yubin


Re: reference the folder name in a folder-hook push command

2017-12-28 Thread Oleg A. Mamontov

Hello,

On Tue, Dec 26, 2017 at 03:23:50PM +, Arkadiusz Drabczyk wrote:

On Tue, Dec 26, 2017 at 06:36:20AM +0800, Yubin Ruan wrote:

Hi,

I have a folder hook like this:

folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'

where I would like to create a file "/tmp/somebox-touched" when I select and
enter a mailbox. As you can see, \1 here should represent the name of the mbox
(as in many Regex). Is there a way to do this so that I do not have to write
rules for all the mbox one by one?


Like that:

folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
set record=$my_oldrecord'
folder-hook . 'push "!touch /tmp/${my_folder}-touched\n"'


Thanks for sharing such an interesting approach. How can it be extended 
to remove the '=' starting character? I've tried to do following:


folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=`echo 
$record | sed s/=//`; set record=$my_oldrecord'

But unfortunately it doesn't work for some reason.

--
Cheers,
Oleg A. Mamontov

mailto: o...@mamontov.net

skype:  lonerr11
cell:   +7 (903) 798-1352


Re: reference the folder name in a folder-hook push command

2017-12-28 Thread Arkadiusz Drabczyk
On Thu, Dec 28, 2017 at 07:07:57PM +0300, Oleg A. Mamontov wrote:
> Hello,
> 
> On Tue, Dec 26, 2017 at 03:23:50PM +, Arkadiusz Drabczyk wrote:
> > On Tue, Dec 26, 2017 at 06:36:20AM +0800, Yubin Ruan wrote:
> > > Hi,
> > > 
> > > I have a folder hook like this:
> > > 
> > > folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'
> > > 
> > > where I would like to create a file "/tmp/somebox-touched" when I select 
> > > and
> > > enter a mailbox. As you can see, \1 here should represent the name of the 
> > > mbox
> > > (as in many Regex). Is there a way to do this so that I do not have to 
> > > write
> > > rules for all the mbox one by one?
> > 
> > Like that:
> > 
> > folder-hook . 'set my_oldrecord=$record; set record=^; set 
> > my_folder=$record; set record=$my_oldrecord'
> > folder-hook . 'push "!touch /tmp/${my_folder}-touched\n"'
> 
> Thanks for sharing such an interesting approach. How can it be extended to
> remove the '=' starting character? I've tried to do following:
> 
> folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=`echo 
> $record | sed s/=//`; set record=$my_oldrecord'
> 
> But unfortunately it doesn't work for some reason.

The best I could come up with:

folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
set record=$my_oldrecord'
folder-hook . 'push "!touch /tmp/$(echo ${my_folder} | sed 's,^=,,)-touched\n"'

The reason the solution you tried doesn't work is probably because
mutt performs shell substitution before parsing the line as said in
the manual:

"It is also possible to substitute the output of a Unix command in an
initialization file. This is accomplished by enclosing the command in
backticks (``). In Example 3.5, "Using external command's output in
configuration files", the output of the Unix command "uname -a" will
be substituted before the line is parsed."

So what shell sees is:

$ echo | sed s/=//

-- 
Arkadiusz Drabczyk 


Re: reference the folder name in a folder-hook push command

2017-12-30 Thread Oleg A. Mamontov

On Fri, Dec 29, 2017 at 07:27:14AM +, Arkadiusz Drabczyk wrote:

On Thu, Dec 28, 2017 at 07:07:57PM +0300, Oleg A. Mamontov wrote:

Hello,

On Tue, Dec 26, 2017 at 03:23:50PM +, Arkadiusz Drabczyk wrote:
> On Tue, Dec 26, 2017 at 06:36:20AM +0800, Yubin Ruan wrote:
> > Hi,
> >
> > I have a folder hook like this:
> >
> > folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'
> >
> > where I would like to create a file "/tmp/somebox-touched" when I select and
> > enter a mailbox. As you can see, \1 here should represent the name of the 
mbox
> > (as in many Regex). Is there a way to do this so that I do not have to write
> > rules for all the mbox one by one?
>
> Like that:
>
> folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
set record=$my_oldrecord'
> folder-hook . 'push "!touch /tmp/${my_folder}-touched\n"'

Thanks for sharing such an interesting approach. How can it be extended to
remove the '=' starting character? I've tried to do following:

folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=`echo 
$record | sed s/=//`; set record=$my_oldrecord'

But unfortunately it doesn't work for some reason.


The best I could come up with:

folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
set record=$my_oldrecord'
folder-hook . 'push "!touch /tmp/$(echo ${my_folder} | sed 's,^=,,)-touched\n"'

The reason the solution you tried doesn't work is probably because
mutt performs shell substitution before parsing the line as said in
the manual:

"It is also possible to substitute the output of a Unix command in an
initialization file. This is accomplished by enclosing the command in
backticks (``). In Example 3.5, "Using external command's output in
configuration files", the output of the Unix command "uname -a" will
be substituted before the line is parsed."

So what shell sees is:

$ echo | sed s/=//


Thank you for suggestion and explanation, but do I understand right that 
there is no way to create internal mutt variable ($my_foo) as

modification of another one ($my_bar)?



--
Arkadiusz Drabczyk 


--
Cheers,
Oleg A. Mamontov

mailto: o...@mamontov.net

skype:  lonerr11
cell:   +7 (903) 798-1352


Re: reference the folder name in a folder-hook push command

2017-12-31 Thread Arkadiusz Drabczyk
On Sat, Dec 30, 2017 at 11:42:41PM +0300, Oleg A. Mamontov wrote:
> Thank you for suggestion and explanation, but do I understand right that
> there is no way to create internal mutt variable ($my_foo) as
> modification of another one ($my_bar)?

None that I'm aware of.
-- 
Arkadiusz Drabczyk