]> granicus.if.org Git - neomutt/commitdiff
Added * option to unattachments command
authorAndrew Marks <amarks@red.ridge.amrx.net>
Fri, 5 Jul 2019 15:44:21 +0000 (08:44 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 5 Aug 2019 09:50:29 +0000 (10:50 +0100)
The * option clears all previous attachments settings.

Co-authored-by: Richard Russon <rich@flatcap.org>
doc/manual.xml.head
init.c

index dc6e98d03544513b8acca0ca281f7079999a460d..2b41c00da901be4bd424d413f841d4945519acfe 100644 (file)
@@ -10854,7 +10854,13 @@ set preferred_languages="fr,en,de"
           <replaceable>mime-type</replaceable>
         </arg>
         <command>attachments</command>
-        <arg choice="plain">?</arg>
+        <arg choice="plain">
+          <option>?</option>
+        </arg>
+        <command>unattachments</command>
+        <arg choice="plain">
+          <option>*</option>
+        </arg>
       </cmdsynopsis>
       <para>
         <emphasis>disposition</emphasis> is the attachment's
@@ -10946,6 +10952,11 @@ attachments  -I message/external-body
         a command will list your current settings in neomuttrc format, so that
         it can be pasted elsewhere.
       </para>
+
+      <para>
+        Entering the command <quote><command>unattachments</command> *</quote>
+        as a command will Clear all attachment settings.
+      </para>
     </sect1>
 
     <sect1 id="mime-lookup">
@@ -18065,6 +18076,18 @@ neomutt mailto:some@one.org?subject=test&amp;cc=other@one.org
             <arg choice="plain">
               <replaceable>mime-type</replaceable>
             </arg>
+            <command>
+              <link linkend="attachments">attachments</link>
+            </command>
+            <arg choice="plain">
+              <option>?</option>
+            </arg>
+            <command>
+              <link linkend="attachments">unattachments</link>
+            </command>
+            <arg choice="plain">
+              <option>*</option>
+            </arg>
           </cmdsynopsis>
         </listitem>
         <listitem>
diff --git a/init.c b/init.c
index 9f3cf162b4328dee4f000ab5460e2e6ea60cdad5..5200b0010168d8fd558012af93d88d9051d892f2 100644 (file)
--- a/init.c
+++ b/init.c
@@ -2273,6 +2273,22 @@ static enum CommandResult parse_unalternates(struct Buffer *buf, struct Buffer *
   return MUTT_CMD_SUCCESS;
 }
 
+/**
+ * mutt_free_attachmatch - Free an AttachMatch - Implements ::list_free_t
+ *
+ * @note We don't free minor because it is either a pointer into major,
+ *       or a static string.
+ */
+void mutt_free_attachmatch(struct AttachMatch **am)
+{
+  if (!am || !*am)
+    return;
+
+  regfree(&(*am)->minor_regex);
+  FREE(&(*am)->major);
+  FREE(am);
+}
+
 /**
  * parse_unattachments - Parse the 'unattachments' command - Implements ::command_t
  */
@@ -2292,6 +2308,17 @@ static enum CommandResult parse_unattachments(struct Buffer *buf, struct Buffer
 
   p = buf->data;
   op = *p++;
+
+  if (op == '*')
+  {
+    mutt_list_free_type(&AttachAllow, (list_free_t) mutt_free_attachmatch);
+    mutt_list_free_type(&AttachExclude, (list_free_t) mutt_free_attachmatch);
+    mutt_list_free_type(&InlineAllow, (list_free_t) mutt_free_attachmatch);
+    mutt_list_free_type(&InlineExclude, (list_free_t) mutt_free_attachmatch);
+    attachments_clean();
+    return 0;
+  }
+
   if ((op != '+') && (op != '-'))
   {
     op = '+';
@@ -2845,22 +2872,6 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags
   return 0;
 }
 
-/**
- * mutt_free_attachmatch - Free an AttachMatch - Implements ::list_free_t
- *
- * @note We don't free minor because it is either a pointer into major,
- *       or a static string.
- */
-void mutt_free_attachmatch(struct AttachMatch **am)
-{
-  if (!am || !*am)
-    return;
-
-  regfree(&(*am)->minor_regex);
-  FREE(&(*am)->major);
-  FREE(am);
-}
-
 /**
  * mutt_free_opts - clean up before quitting
  */