Index: ChangeLog
===================================================================
--- ChangeLog	(revision 7360fabdd3382148cdd83b2bcb1ea86f19f02c94)
+++ ChangeLog	(revision d36f2cbef9f608ed68766f9c026d4376906953d6)
@@ -29,4 +29,10 @@
 	        matching current" and "move to previous message 
 		matching current"
+	Added variables edit:maxfillcols and edit:maxwrapcols which 
+	        will limit how wide editing paragraphs may get before
+		they get wrapped.  Default is 70 columns each.
+	Added smartzpunt command with key binding of "C-x k".
+	        This starts a zpunt command filled in with 
+		the proposed zpunt.
 	
 1.2.0-pre-erikdevel-17
Index: commands.c
===================================================================
--- commands.c	(revision 7360fabdd3382148cdd83b2bcb1ea86f19f02c94)
+++ commands.c	(revision d36f2cbef9f608ed68766f9c026d4376906953d6)
@@ -148,4 +148,10 @@
 	      "getsubs retrieves the current subscriptions from the server\n"
 	      "and displays them.\n"),
+
+  OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE,
+	      "creates a zpunt based on the current message",
+	      "smartnarrow [-i | --instance]",
+	      "Starts a zpunt command based on the current message's class\n"
+	      "(and instance if -i is specified).\n"),
 
   OWLCMD_ARGS("zpunt", owl_command_zpunt, OWL_CTX_ANY,
@@ -1386,4 +1392,16 @@
 }
 
+char *owl_command_smartzpunt(int argc, char **argv, char *buff) {
+  if (argc == 1) {
+    owl_function_smartzpunt(0);
+  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
+    owl_function_smartzpunt(1);
+  } else {
+    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);    
+  }
+  return NULL;
+}
+
+
 
 /*********************************************************************/
Index: editwin.c
===================================================================
--- editwin.c	(revision 1aee7d914de75510e7cf09c452bad63b2dad2166)
+++ editwin.c	(revision d36f2cbef9f608ed68766f9c026d4376906953d6)
@@ -21,10 +21,8 @@
   e->winlines=winlines;
   e->wincols=wincols;
-  if (wincols > 80) {
-    e->fillcol=80-9;
-  } else {
-    e->fillcol=wincols-9;
-  }
-  e->wrapcol=wincols-9;
+  e->fillcol=owl_editwin_limit_maxcols(wincols-1, 
+				       owl_global_get_edit_maxfillcols(&g));
+  e->wrapcol=owl_editwin_limit_maxcols(wincols-1, 
+				       owl_global_get_edit_maxwrapcols(&g));
   e->curswin=win;
   e->style=style;
@@ -42,10 +40,8 @@
   e->winlines=winlines;
   e->wincols=wincols;
-  if (wincols > 80) {
-    e->fillcol=80-8;
-  } else {
-    e->fillcol=wincols-8;
-  }
-  e->wrapcol=wincols-9;
+  e->fillcol=owl_editwin_limit_maxcols(wincols-1, 
+				       owl_global_get_edit_maxfillcols(&g));
+  e->wrapcol=owl_editwin_limit_maxcols(wincols-1, 
+				       owl_global_get_edit_maxwrapcols(&g));
 }
 
@@ -56,4 +52,12 @@
 void owl_editwin_set_dotsend(owl_editwin *e) {
   e->dotsend=1;
+}
+
+int owl_editwin_limit_maxcols(int v, int maxv) {
+  if (maxv > 5 && v > maxv) {
+    return maxv;
+  } else {
+    return v;
+  }
 }
 
Index: functions.c
===================================================================
--- functions.c	(revision 7360fabdd3382148cdd83b2bcb1ea86f19f02c94)
+++ functions.c	(revision d36f2cbef9f608ed68766f9c026d4376906953d6)
@@ -218,5 +218,5 @@
 			 skip_deleted?" non-deleted":"",
 			 filter?" in ":"", filter?filter:"");
-    owl_function_beep();
+    if (!skip_deleted) owl_function_beep();
   }
 
@@ -267,5 +267,5 @@
 			 skip_deleted?" non-deleted":"",
 			 filter?" in ":"", filter?filter:"");
-    owl_function_beep();
+    if (!skip_deleted) owl_function_beep();
   }
 
@@ -1843,4 +1843,52 @@
 }
 
+void owl_function_smartzpunt(int type) {
+  /* Starts a zpunt command based on the current class,instance pair. 
+   * If type=0, uses just class.  If type=1, uses instance as well. */
+  owl_view *v;
+  owl_message *m;
+  char *cmd, *cmdprefix, *mclass, *minst;
+  
+  v=owl_global_get_current_view(&g);
+  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
+
+  if (owl_view_get_size(v)==0) {
+    owl_function_makemsg("No message selected\n");
+    return;
+  }
+
+  /* for now we skip admin messages. */
+  if (owl_message_is_admin(m)
+      || owl_message_is_login(m)
+      || !owl_message_is_zephyr(m)) {
+    owl_function_makemsg("smartzpunt doesn't support this message type.");
+    return;
+  }
+
+  mclass = owl_message_get_class(m);
+  minst = owl_message_get_instance(m);
+  if (!mclass || !*mclass || *mclass==' '
+      || (!strcasecmp(mclass, "message") && !strcasecmp(minst, "personal"))
+      || (type && (!minst || !*minst|| *minst==' '))) {
+    owl_function_makemsg("smartzpunt can't safely do this for <%s,%s>",
+			 mclass, minst);
+  } else {
+    cmdprefix = "start-command zpunt ";
+    cmd = owl_malloc(strlen(cmdprefix)+strlen(mclass)+strlen(minst)+3);
+    strcpy(cmd, cmdprefix);
+    strcat(cmd, mclass);
+    if (type) {
+      strcat(cmd, " ");
+      strcat(cmd, minst);
+    } else {
+      strcat(cmd, " *");
+    }
+    owl_function_command(cmd);
+    owl_free(cmd);
+  }
+}
+
+
+
 void owl_function_color_current_filter(char *color) {
   owl_filter *f;
Index: keys.c
===================================================================
--- keys.c	(revision 7360fabdd3382148cdd83b2bcb1ea86f19f02c94)
+++ keys.c	(revision d36f2cbef9f608ed68766f9c026d4376906953d6)
@@ -188,4 +188,5 @@
   BIND_CMD("d",       "delete",         "mark message for deletion");
   BIND_CMD("M-D",     "delete view",    "mark all messages in view for deletion");
+  BIND_CMD("C-x k",   "smartzpunt -i",  "zpunt current <class,instance>");
 
   BIND_CMD("X",   "( expunge ; view --home )", "expunge deletions and switch to home view");
Index: variable.c
===================================================================
--- variable.c	(revision 1aee7d914de75510e7cf09c452bad63b2dad2166)
+++ variable.c	(revision d36f2cbef9f608ed68766f9c026d4376906953d6)
@@ -119,4 +119,10 @@
   OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all",
 	         "home view to switch to after 'X'" ),
+
+  OWLVAR_INT(    "edit:maxfillcols" /* %OwlVarStub:edit_maxfillcols */, 70,
+	         "maximum number of columns for M-q to fill text to" ),
+
+  OWLVAR_INT(    "edit:maxwrapcols" /* %OwlVarStub:edit_maxwrapcols */, 70,
+	         "maximum number of columns for line-wrapping" ),
 
   OWLVAR_INT_FULL( "typewinsize" /* %OwlVarStub:typwin_lines */, 
