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

abort of edit-type in pager



While reading a message I sometimes press edit-type (^E) in order to
check the coding of the message or just by mistake. When I then press
abort (^G) the pager jumps up to the top of the message and I have to
scroll down to the place I was before. This is not the behavior I expect
when aborting, since I would prefer to continue reading the message at
the same spot I was before instead of jumping to the top.

In the present (1.5.6) implementation, the edit-type command is decoded
in the index menu and the message is redisplayed if the edit-type
command was issued in the pager.

In the attached patch (relative to the CVS head branch), the edit-type
command is decoded in the pager. If aborted no action is taken,
otherwise the message will be redisplayed as before even if the type
wasn't changed.


Anders Helmersson
Index: commands.c
===================================================================
RCS file: /home/roessler/cvs/mutt/commands.c,v
retrieving revision 3.23
diff -u -r3.23 commands.c
--- commands.c  12 Apr 2004 20:33:33 -0000      3.23
+++ commands.c  16 May 2004 17:00:17 -0000
@@ -847,7 +847,7 @@
   mutt_message ("Mutt %s (%s)", MUTT_VERSION, ReleaseDate);
 }
 
-void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
+int mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
 {
   char buf[LONG_STRING];
   char obuf[LONG_STRING];
@@ -880,7 +880,7 @@
   
   if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
       buf[0] == 0)
-    return;
+    return -1;
   
   /* clean up previous junk */
   mutt_free_parameter (&b->parameter);
@@ -933,6 +933,7 @@
 
     h->security |= crypt_query (b);
   }
+  return 0;
 }
 
 
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 16 May 2004 17:00:25 -0000
@@ -1170,14 +1170,7 @@
         CHECK_VISIBLE;
        CHECK_ATTACH;
        mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
-       /* if we were in the pager, redisplay the message */
-       if (menu->menu == MENU_PAGER)
-       {
-         op = OP_DISPLAY_MESSAGE;
-         continue;
-       }
-        else
-         menu->redraw = REDRAW_CURRENT;
+       menu->redraw = REDRAW_CURRENT;
        break;
 
       case OP_MAIN_NEXT_UNDELETED:
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     16 May 2004 17:00:37 -0000
@@ -2484,6 +2484,27 @@
        MAYBE_REDRAW (redraw);
        break;
 
+      case OP_EDIT_TYPE:
+       if (extra->bdy)
+       {
+         r = mutt_edit_content_type (extra->hdr, extra->bdy, NULL);
+         if (r != -1)
+         {
+           ch = -1;
+           rc = OP_VIEW_ATTACH;
+         }
+       }
+       else
+       {
+         r = mutt_edit_content_type (extra->hdr, extra->hdr->content, NULL);
+         if (r != -1)
+         {
+           ch = -1;
+           rc = OP_DISPLAY_MESSAGE; 
+         }
+       }
+       break;
+
       case OP_SHELL_ESCAPE:
        mutt_shell_escape ();
        MAYBE_REDRAW (redraw);
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    16 May 2004 17:00:41 -0000
@@ -159,7 +159,7 @@
 void mutt_default_save (char *, size_t, HEADER *);
 void mutt_display_address (ENVELOPE *);
 void mutt_display_sanitize (char *);
-void mutt_edit_content_type (HEADER *, BODY *, FILE *);
+int  mutt_edit_content_type (HEADER *, BODY *, FILE *);
 void mutt_edit_file (const char *, const char *);
 void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
 void mutt_curses_error (const char *, ...);
Index: recvattach.c
===================================================================
RCS file: /home/roessler/cvs/mutt/recvattach.c,v
retrieving revision 3.13
diff -u -r3.13 recvattach.c
--- recvattach.c        12 Apr 2004 20:33:33 -0000      3.13
+++ recvattach.c        16 May 2004 17:00:46 -0000
@@ -803,17 +803,6 @@
        else
          op = OP_NULL;
        break;
-      case OP_EDIT_TYPE:
-       /* when we edit the content-type, we should redisplay the attachment
-          immediately */
-       mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
-        if (idxmax)
-        {
-         mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
-         idx = *idxp;
-       }
-        op = OP_VIEW_ATTACH;
-       break;
       /* functions which are passed through from the pager */
       case OP_CHECK_TRADITIONAL:
         if (!(WithCrypto & APPLICATION_PGP) || (hdr && hdr->security & 
PGP_TRADITIONAL_CHECKED))