Re: is it possible to set pager search pattern based on message-hook?

2010-10-14 Thread Will Fiveash
On Wed, Oct 13, 2010 at 02:50:50PM -0500, Will Fiveash wrote:
 On Tue, Sep 28, 2010 at 03:40:16PM -0500, David Champion wrote:
  * On 28 Sep 2010, Will Fiveash wrote: 
   I'd like to set search to a particular pattern when I view a message
   with a particular subject.  The reason I want this is that some messages
   I receive have sections with section delimiters and I want search
   initialized to that delimiter pattern.  Is this possible and if so can
   someone give me a hint as to how?
  
  message-hook '~s pattern' 'macro pager n searchkill-line^===enter; 
  macro pager / bind pager n search-next; bind pager / search; push /'
  message-hook . 'bind pager n search-next'
  
  Untested (naturally) and probably doesn't work due to quoting, but maybe
  a start.
 
 What I ended up using is:
 
 message-hook '~s ^SANS NewsBites ' 'push search^ --entertop'

Actually, that's not really working for me as it interferes with other
mutt functions like saving a message.  For example when I'm in index
mode and I have the following setting:

message-hook '~s ^CR ' 'push :macro pager / search^===\\ enter'

and I select a message with Subject: CR etc...
and I type s to save it I see:

Create :macropager/search^===\? ([yes]/no):

I don't understand why message-hook is affecting the save command when
there is a separate save-hook for this.

-- 
Will Fiveash
Oracle
Austin, TX, USA
Internal Solaris Kerberos/GSS/SASL website: http://kerberos.sfbay.sun.com
http://opensolaris.org/os/project/kerberos/


Re: is it possible to set pager search pattern based on message-hook?

2010-10-14 Thread Will Fiveash
On Thu, Oct 14, 2010 at 04:36:07PM -0500, Will Fiveash wrote:
 Actually, that's not really working for me as it interferes with other
 mutt functions like saving a message.  For example when I'm in index
 mode and I have the following setting:
 
 message-hook '~s ^CR ' 'push :macro pager / search^===\\ enter'
 
 and I select a message with Subject: CR etc...
 and I type s to save it I see:
 
 Create :macropager/search^===\? ([yes]/no):
 
 I don't understand why message-hook is affecting the save command when
 there is a separate save-hook for this.

truss is showing this call sequence when I try to save the message:

/1...@1:   - mutt_save_message(0x818e010, 0x1, 0x0, 0x0)
/1...@1: - mutt_message_hook(0x828dc48, 0x818e010, 0x80, 0x810df76)

Is that correct?

I ask that because the mutt docs state this about message-hook:

   Usage: message-hook [!]pattern command

   This command can be used to execute arbitrary configuration commands
   before viewing or formatting a message based upon information about
   the message. command is executed if the pattern matches the message to
   be displayed. When multiple matches occur, commands are executed in
   the order they are specified in the muttrc.

It is not obvious to me why mutt_save_message is calling
mutt_message_hook.

-- 
Will Fiveash


Re: is it possible to set pager search pattern based on message-hook?

2010-10-14 Thread Will Fiveash
On Thu, Oct 14, 2010 at 05:00:00PM -0500, Will Fiveash wrote:
 On Thu, Oct 14, 2010 at 04:36:07PM -0500, Will Fiveash wrote:
  Actually, that's not really working for me as it interferes with other
  mutt functions like saving a message.  For example when I'm in index
  mode and I have the following setting:
  
  message-hook '~s ^CR ' 'push :macro pager / search^===\\ enter'
  
  and I select a message with Subject: CR etc...
  and I type s to save it I see:
  
  Create :macropager/search^===\? ([yes]/no):
  
  I don't understand why message-hook is affecting the save command when
  there is a separate save-hook for this.
 
 truss is showing this call sequence when I try to save the message:
 
 /1...@1:   - mutt_save_message(0x818e010, 0x1, 0x0, 0x0)
 /1...@1: - mutt_message_hook(0x828dc48, 0x818e010, 0x80, 0x810df76)
 
 Is that correct?
 
 I ask that because the mutt docs state this about message-hook:
 
Usage: message-hook [!]pattern command
 
This command can be used to execute arbitrary configuration commands
before viewing or formatting a message based upon information about
the message. command is executed if the pattern matches the message to
be displayed. When multiple matches occur, commands are executed in
the order they are specified in the muttrc.
 
 It is not obvious to me why mutt_save_message is calling
 mutt_message_hook.

And when I comment out the calls to mutt_message_hook() in
mutt_save_message() mutt works as I expect which allows me to set:

message-hook '~s ^CR ' 'push search^=== enter'

and this does not interfere with the save command.

-- 
Will Fiveash


[PATCH] Re: is it possible to set pager search pattern based on message-hook?

2010-10-14 Thread Will Fiveash
I think I have a better fix.  I've included a patch that introduces a
search_regex pager setting.  This allows one to initialize the search
string via a message-hook when entering the mutt pager.  Here is an
example of how to use it:

message-hook '~s ^CR ' 'set search_regex=^=== '

This has fewer side effects than using push.

# HG changeset patch
# User Will Fiveash will.five...@oracle.com
# Date 1287100788 18000
# Branch HEAD
# Node ID bcb7f904515ed09ccc7ac9cbe05cf814d02c3484
# Parent  6eec86da3108932029df4d7d6b5eadb89c2add6b
new search_regex pager variable

diff -r 6eec86da3108 -r bcb7f904515e globals.h
--- a/globals.h Thu Oct 14 18:59:48 2010 -0500
+++ b/globals.h Thu Oct 14 18:59:48 2010 -0500
@@ -114,6 +114,7 @@
 WHERE char *QueryFormat;
 WHERE char *Realname;
 WHERE short SearchContext;
+WHERE char *SearchRegex;
 WHERE char *SendCharset;
 WHERE char *Sendmail;
 WHERE char *Shell;
diff -r 6eec86da3108 -r bcb7f904515e init.h
--- a/init.hThu Oct 14 18:59:48 2010 -0500
+++ b/init.hThu Oct 14 18:59:48 2010 -0500
@@ -2450,6 +2450,11 @@
   ** For the pager, this variable specifies the number of lines shown
   ** before search results. By default, search results will be top-aligned.
   */
+  { search_regex,DT_STR,  R_NONE, UL SearchRegex, UL  },
+  /*
+  ** .pp
+  ** For the pager, this variable specifies an initial search regex.
+  */
   { send_charset,DT_STR,  R_NONE, UL SendCharset, UL 
us-ascii:iso-8859-1:utf-8 },
   /*
   ** .pp
diff -r 6eec86da3108 -r bcb7f904515e pager.c
--- a/pager.c   Thu Oct 14 18:59:48 2010 -0500
+++ b/pager.c   Thu Oct 14 18:59:48 2010 -0500
@@ -1600,6 +1600,9 @@
 
   /* Initialize variables */
 
+  if (SearchRegex != NULL)
+strfcpy (searchbuf, SearchRegex, sizeof (searchbuf));
+
   if (IsHeader (extra)  !extra-hdr-read)
   {
 Context-msgnotreadyet = extra-hdr-msgno;


Re: is it possible to set pager search pattern based on message-hook?

2010-10-13 Thread Will Fiveash
On Tue, Sep 28, 2010 at 03:40:16PM -0500, David Champion wrote:
 * On 28 Sep 2010, Will Fiveash wrote: 
  I'd like to set search to a particular pattern when I view a message
  with a particular subject.  The reason I want this is that some messages
  I receive have sections with section delimiters and I want search
  initialized to that delimiter pattern.  Is this possible and if so can
  someone give me a hint as to how?
 
 message-hook '~s pattern' 'macro pager n searchkill-line^===enter; 
 macro pager / bind pager n search-next; bind pager / search; push /'
 message-hook . 'bind pager n search-next'
 
 Untested (naturally) and probably doesn't work due to quoting, but maybe
 a start.

What I ended up using is:

message-hook '~s ^SANS NewsBites ' 'push search^ --entertop'

Thanks again for the message-hook/push hint.

-- 
Will Fiveash
Oracle
Austin, TX, USA
Internal Solaris Kerberos/GSS/SASL website: http://kerberos.sfbay.sun.com
http://opensolaris.org/os/project/kerberos/


is it possible to set pager search pattern based on message-hook?

2010-09-28 Thread Will Fiveash
I'd like to set search to a particular pattern when I view a message
with a particular subject.  The reason I want this is that some messages
I receive have sections with section delimiters and I want search
initialized to that delimiter pattern.  Is this possible and if so can
someone give me a hint as to how?

-- 
Will Fiveash


Re: is it possible to set pager search pattern based on message-hook?

2010-09-28 Thread David Champion
* On 28 Sep 2010, Will Fiveash wrote: 
 I'd like to set search to a particular pattern when I view a message
 with a particular subject.  The reason I want this is that some messages
 I receive have sections with section delimiters and I want search
 initialized to that delimiter pattern.  Is this possible and if so can
 someone give me a hint as to how?

message-hook '~s pattern' 'macro pager n searchkill-line^===enter; 
macro pager / bind pager n search-next; bind pager / search; push /'
message-hook . 'bind pager n search-next'

Untested (naturally) and probably doesn't work due to quoting, but maybe
a start.

-- 
David Champion  *  d...@uchicago.edu  *  IT Services  *  University of Chicago


Re: is it possible to set pager search pattern based on message-hook?

2010-09-28 Thread Rado S
=- Will Fiveash wrote on Tue 28.Sep'10 at 14:46:06 -0500 -=

 I'd like to set search to a particular pattern when I view a message
 with a particular subject.  The reason I want this is that some messages
 I receive have sections with section delimiters and I want search
 initialized to that delimiter pattern.  Is this possible and if so can
 someone give me a hint as to how?

message-hook

-- 
© Rado S. -- You must provide YOUR effort for your goal!
EVERY effort counts: at least to show your attitude.
You're responsible for ALL you do: you get what you give.


Re: is it possible to set pager search pattern based on message-hook?

2010-09-28 Thread Will Fiveash
On Wed, Sep 29, 2010 at 12:01:11AM +0200, Rado S wrote:
 =- Will Fiveash wrote on Tue 28.Sep'10 at 14:46:06 -0500 -=
 
  I'd like to set search to a particular pattern when I view a message
  with a particular subject.  The reason I want this is that some messages
  I receive have sections with section delimiters and I want search
  initialized to that delimiter pattern.  Is this possible and if so can
  someone give me a hint as to how?
 
 message-hook

Thank


Re: is it possible to set pager search pattern based on message-hook?

2010-09-28 Thread Will Fiveash
On Tue, Sep 28, 2010 at 03:40:16PM -0500, David Champion wrote:
 * On 28 Sep 2010, Will Fiveash wrote: 
  I'd like to set search to a particular pattern when I view a message
  with a particular subject.  The reason I want this is that some messages
  I receive have sections with section delimiters and I want search
  initialized to that delimiter pattern.  Is this possible and if so can
  someone give me a hint as to how?
 
 message-hook '~s pattern' 'macro pager n searchkill-line^===enter; 
 macro pager / bind pager n search-next; bind pager / search; push /'
 message-hook . 'bind pager n search-next'
 
 Untested (naturally) and probably doesn't work due to quoting, but maybe
 a start.

Thanks for the tip, I will check it out.

-- 
Will Fiveash