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

Re: Commands should not stop and cause an error



On Thu, 08 Jul 2004, TAKAHASHI Tamotsu wrote:
> On Fri, 11 Jun 2004, Jens Paulus wrote:
> > > I disagree, but shouldn't "pager_stop" control their behavior?
> > 
> > this may be a good idea. The varialbe pager_stop could make all these
> > commands stop or not stop at the beginning or end of the message.
> > 
> > pager next-line
> > pager previous-line
> > pager next-page
> > pager previous-page
> > 
> > Maybe this is the right solution.
> 
> My patch (a dirty hack) is attached.
> I wrote this hack with 1.4.1.
> But you can apply this to 1.5.6 or CVS HEAD.

I attach a patch for 1.5.6 CVS HEAD.
Function "half-up" is also affected now.
Seems not so dirty for me.

> Try these settings:
>  set pager_linestop
>  set pager_prevstop

No, unset them please. I was confused.

-- 
tamo
Index: OPS
===================================================================
RCS file: /home/roessler/cvs/mutt/OPS,v
retrieving revision 3.5
diff -u -r3.5 OPS
--- OPS 4 Jul 2003 17:07:22 -0000       3.5
+++ OPS 9 Jul 2004 13:19:25 -0000
@@ -56,6 +56,7 @@
 OP_DISPLAY_ADDRESS "display full address of sender"
 OP_DISPLAY_HEADERS "display message and toggle header weeding"
 OP_DISPLAY_MESSAGE "display a message"
+OP_DISPLAY_MESSAGE_BOTTOM "display a message's tail"
 OP_EDIT_MESSAGE "edit the raw message"
 OP_EDITOR_BACKSPACE "delete the char in front of the cursor"
 OP_EDITOR_BACKWARD_CHAR "move the cursor one character to the left"
@@ -115,6 +116,7 @@
 OP_MAIN_PREV_THREAD "jump to previous thread"
 OP_MAIN_PREV_SUBTHREAD "jump to previous subthread"
 OP_MAIN_PREV_UNDELETED "move to the previous undeleted message"
+OP_MAIN_PREV_UNDELETED_BOTTOM "view the bottom of the prev-undeleted msg"
 OP_MAIN_PREV_NEW "jump to the previous new message"
 OP_MAIN_PREV_NEW_THEN_UNREAD "jump to the previous new or unread message"
 OP_MAIN_PREV_UNREAD "jump to the previous unread message"
Index: commands.c
===================================================================
RCS file: /home/roessler/cvs/mutt/commands.c,v
retrieving revision 3.24
diff -u -r3.24 commands.c
--- commands.c  26 Jun 2004 08:45:29 -0000      3.24
+++ commands.c  9 Jul 2004 13:19:26 -0000
@@ -54,7 +54,7 @@
 /* The folder the user last saved to.  Used by ci_save_message() */
 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
 
-int mutt_display_message (HEADER *cur)
+int mutt_display_message (HEADER *cur, int bottom)
 {
   char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
   int rc = 0, builtin = 0;
@@ -204,7 +204,7 @@
     memset (&info, 0, sizeof (pager_t));
     info.hdr = cur;
     info.ctx = Context;
-    rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
+    rc = mutt_pager (NULL, tempfile, (M_PAGER_MESSAGE | bottom), &info);
   }
   else
   {
Index: curs_main.c
===================================================================
RCS file: /home/roessler/cvs/mutt/curs_main.c,v
retrieving revision 3.17
diff -u -r3.17 curs_main.c
--- curs_main.c 12 Apr 2004 20:33:33 -0000      3.17
+++ curs_main.c 9 Jul 2004 13:19:26 -0000
@@ -24,6 +24,7 @@
 #include "sort.h"
 #include "buffy.h"
 #include "mx.h"
+#include "pager.h"
 
 #ifdef USE_POP
 #include "pop.h"
@@ -1110,6 +1111,7 @@
        set_option (OPTSEARCHINVALID);
        break;
 
+      case OP_DISPLAY_MESSAGE_BOTTOM:
       case OP_DISPLAY_MESSAGE:
       case OP_DISPLAY_HEADERS: /* don't weed the headers */
 
@@ -1132,7 +1134,9 @@
            menu->current = mutt_thread_next_unread (Context, CURHDR);
        }
  
-       if ((op = mutt_display_message (CURHDR)) == -1)
+       if ((op = mutt_display_message
+           (CURHDR, (op == OP_DISPLAY_MESSAGE_BOTTOM) ? M_PAGER_BOTTOM : 0)
+           ) == -1)
        {
          unset_option (OPTNEEDRESORT);
          break;
@@ -1225,6 +1229,7 @@
          menu->redraw = REDRAW_MOTION;
        break;
 
+      case OP_MAIN_PREV_UNDELETED_BOTTOM:
       case OP_MAIN_PREV_UNDELETED:
 
        CHECK_MSGCOUNT;
@@ -1242,7 +1247,7 @@
        }
        else if (menu->menu == MENU_PAGER)
        {
-         op = OP_DISPLAY_MESSAGE;
+         op = (op == OP_MAIN_PREV_UNDELETED_BOTTOM) ? 
OP_DISPLAY_MESSAGE_BOTTOM : OP_DISPLAY_MESSAGE;
          continue;
        }
        else
Index: init.h
===================================================================
RCS file: /home/roessler/cvs/mutt/init.h,v
retrieving revision 3.48
diff -u -r3.48 init.h
--- init.h      17 Jun 2004 20:36:13 -0000      3.48
+++ init.h      9 Jul 2004 13:19:27 -0000
@@ -1219,7 +1219,22 @@
   ** .pp
   ** When set, the internal-pager will \fBnot\fP move to the next message
   ** when you are at the end of a message and invoke the \fInext-page\fP
+  ** or \fIhalf-down\fP function.
+  */
+  { "pager_linestop",  DT_BOOL, R_NONE, OPTPAGERLINESTOP, 1 },
+  /*
+  ** .pp
+  ** When set, the internal-pager will \fBnot\fP move to the next message
+  ** when you are at the end of a message and invoke the \fInext-line\fP
   ** function.
+  */
+  { "pager_prevstop",  DT_BOOL, R_NONE, OPTPAGERPREVSTOP, 1 },
+  /*
+  ** .pp
+  ** When set, the internal-pager will \fBnot\fP move to the previous message
+  ** when you are at the top of a message and invoke the \fIprevious-page\fP
+  ** or \fhalf-up\fP function (when $$pager_stop is set). This affects the
+  ** \fIprevious-line\fP function, too (when $$pager_linestop is set).
   */
   { "pgp_autosign",    DT_SYN,  R_NONE, UL "crypt_autosign", 0 },
   { "crypt_autosign",  DT_BOOL, R_NONE, OPTCRYPTAUTOSIGN, 0 },
Index: mutt.h
===================================================================
RCS file: /home/roessler/cvs/mutt/mutt.h,v
retrieving revision 3.28
diff -u -r3.28 mutt.h
--- mutt.h      17 Jun 2004 20:36:13 -0000      3.28
+++ mutt.h      9 Jul 2004 13:19:28 -0000
@@ -385,6 +385,8 @@
   OPTMIMEFORWDECODE,
   OPTNARROWTREE,
   OPTPAGERSTOP,
+  OPTPAGERLINESTOP,
+  OPTPAGERPREVSTOP,
   OPTPIPEDECODE,
   OPTPIPESPLIT,
 #ifdef USE_POP
Index: pager.c
===================================================================
RCS file: /home/roessler/cvs/mutt/pager.c,v
retrieving revision 3.14
diff -u -r3.14 pager.c
--- pager.c     12 Apr 2004 20:33:33 -0000      3.14
+++ pager.c     9 Jul 2004 13:19:28 -0000
@@ -1664,6 +1664,21 @@
 
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
     {
+      if (flags & M_PAGER_BOTTOM)
+      {
+       if (lineInfo[topline].offset < sb.st_size - 1)
+       {
+         i = topline;
+         while (display_line (fp, &last_pos, &lineInfo, i, &lastLine, 
+                               &maxLine, has_types, 
+                               &QuoteList, &q_level, &force_redraw,
+                               &SearchRE) == 0)
+           i++;
+         topline = upNLines (bodylen, lineInfo, lastLine, hideQuoted);
+       }
+       flags -= M_PAGER_BOTTOM;
+      }
+
       do {
        move (bodyoffset, 0);
        curline = oldtopline = topline;
@@ -1845,8 +1860,14 @@
        {
          topline = upNLines (bodylen-PagerContext, lineInfo, topline, 
hideQuoted);
        }
-       else
+       else if ((option (OPTPAGERSTOP)) || (option (OPTPAGERPREVSTOP)))
          mutt_error _("Top of message is shown.");
+       else
+       {
+         /* top of the current message, so display the previous message. */
+         rc = OP_MAIN_PREV_UNDELETED_BOTTOM;
+         ch = -1;
+       }
        break;
 
       case OP_NEXT_LINE:
@@ -1860,15 +1881,27 @@
              topline++;
          }
        }
-       else
+       else if (option (OPTPAGERLINESTOP))
          mutt_error _("Bottom of message is shown.");
+       else
+       {
+         /* end of the current message, so display the next message. */
+         rc = OP_MAIN_NEXT_UNDELETED;
+         ch = -1;
+       }
        break;
 
       case OP_PREV_LINE:
        if (topline)
          topline = upNLines (1, lineInfo, topline, hideQuoted);
-       else
+       else if ((option (OPTPAGERLINESTOP)) || (option (OPTPAGERPREVSTOP)))
          mutt_error _("Top of message is shown.");
+       else
+       {
+         /* top of the current message, so display the previous message. */
+         rc = OP_MAIN_PREV_UNDELETED_BOTTOM;
+         ch = -1;
+       }
        break;
 
       case OP_PAGER_TOP:
@@ -1881,8 +1914,14 @@
       case OP_HALF_UP:
        if (topline)
          topline = upNLines (bodylen/2, lineInfo, topline, hideQuoted);
-       else
+       else if ((option (OPTPAGERSTOP)) || (option (OPTPAGERPREVSTOP)))
          mutt_error _("Top of message is shown.");
+       else
+       {
+         /* top of the current message, so display the previous message. */
+         rc = OP_MAIN_PREV_UNDELETED_BOTTOM;
+         ch = -1;
+       }
        break;
 
       case OP_HALF_DOWN:
Index: pager.h
===================================================================
RCS file: /home/roessler/cvs/mutt/pager.h,v
retrieving revision 3.1
diff -u -r3.1 pager.h
--- pager.h     11 Dec 2002 11:19:40 -0000      3.1
+++ pager.h     9 Jul 2004 13:19:28 -0000
@@ -30,6 +30,7 @@
 #define M_PAGER_RETWINCH       (1<<7)  /* need reformatting on SIGWINCH */
 #define M_PAGER_MESSAGE                (M_SHOWCOLOR | M_PAGER_MARKER)
 #define M_PAGER_ATTACHMENT     (1<<8)
+#define M_PAGER_BOTTOM         (1<<9)  /* jump to the bottom */
 
 #define M_DISPLAYFLAGS (M_SHOW | M_PAGER_NSKIP | M_PAGER_MARKER)
 
Index: protos.h
===================================================================
RCS file: /home/roessler/cvs/mutt/protos.h,v
retrieving revision 3.19
diff -u -r3.19 protos.h
--- protos.h    1 Feb 2004 17:10:43 -0000       3.19
+++ protos.h    9 Jul 2004 13:19:29 -0000
@@ -259,7 +259,7 @@
 int mutt_compose_attachment (BODY *a);
 int mutt_copy_body (FILE *, BODY **, BODY *);
 int mutt_decode_save_attachment (FILE *, BODY *, char *, int, int);
-int mutt_display_message (HEADER *h);
+int mutt_display_message (HEADER *h, int);
 int mutt_edit_attachment(BODY *);
 int mutt_edit_message (CONTEXT *, HEADER *);
 int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags);