Subject: bug#48683: 28.0.50; [PATCH] Feature suggestion gnus-summary-toggle-mark-as-processable

From: Alex Bochannek <[email-masked]>
Date: Wed, 26 May 2021 12:57:06 -0700

(Not sure if bug-gnu-emacs is the right place to send things like this,
please let me know if there is a better list.)

I have been missing a article process mark toggle for a while and would
like to propose the below patch. If "+" is not an appropriate key to use
for this, I am happy to accept an alternative.

diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 7d6fa4cb5c..2862faadf0 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -6628,6 +6628,13 @@ Setting Process Marks
 Remove the process mark, if any, from the current article
 (@code{gnus-summary-unmark-as-processable}).
 
+@item M P +
+@itemx +
+@kindex M P + @r{(Summary)}
+@kindex + @r{(Summary)}
+Toggle the process mark of the current article
+(@code{gnus-summary-toggle-mark-as-processable}).
+
 @item M P U
 @kindex M P U @r{(Summary)}
 @findex gnus-summary-unmark-all-processable
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index aa4c753287..93ea117ff1 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -1948,6 +1948,7 @@ gnus-summary-mode-map
   "e" gnus-summary-edit-article
   "#" gnus-summary-mark-as-processable
   "\M-#" gnus-summary-unmark-as-processable
+  "+" gnus-summary-toggle-mark-as-processable
   "\M-\C-t" gnus-summary-toggle-threads
   "\M-\C-s" gnus-summary-show-thread
   "\M-\C-h" gnus-summary-hide-thread
@@ -2046,6 +2047,7 @@ gnus-summary-mode-map
   "B" gnus-summary-remove-bookmark
   "#" gnus-summary-mark-as-processable
   "\M-#" gnus-summary-unmark-as-processable
+  "+" gnus-summary-toggle-mark-as-processable
   "S" gnus-summary-limit-include-expunged
   "C" gnus-summary-catchup
   "H" gnus-summary-catchup-to-here
@@ -2336,6 +2338,7 @@ gnus-summary-mode-map
 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
   "p" gnus-summary-mark-as-processable
   "u" gnus-summary-unmark-as-processable
+  "+" gnus-summary-toggle-mark-as-processable
   "U" gnus-summary-unmark-all-processable
   "v" gnus-uu-mark-over
   "s" gnus-uu-mark-series
@@ -2776,6 +2779,7 @@ gnus-summary-make-menu-bar
 	("Process Mark"
 	 ["Set mark" gnus-summary-mark-as-processable t]
 	 ["Remove mark" gnus-summary-unmark-as-processable t]
+	 ["Toggle mark" gnus-summary-toggle-mark-as-processable t]
 	 ["Remove all marks" gnus-summary-unmark-all-processable t]
 	 ["Invert marks" gnus-uu-invert-processable t]
 	 ["Mark above" gnus-uu-mark-over t]
@@ -10951,10 +10955,15 @@ gnus-summary-mark-as-processable
 	  (n (abs n)))
       (while (and
 	      (> n 0)
-	      (if unmark
-		  (gnus-summary-remove-process-mark
-		   (gnus-summary-article-number))
-		(gnus-summary-set-process-mark (gnus-summary-article-number)))
+	      (let ((article (gnus-summary-article-number)))
+		(cond ((eq nil unmark)
+		       (gnus-summary-set-process-mark article))
+		      ((eq t unmark)
+		       (gnus-summary-remove-process-mark article))
+		      ((eq 'toggle unmark)
+		       (if (memq article gnus-newsgroup-processable)
+			   (gnus-summary-remove-process-mark article)
+			 (gnus-summary-set-process-mark article)))))
 	      (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
 	(setq n (1- n)))
       (when (/= 0 n)
@@ -10970,6 +10979,13 @@ gnus-summary-unmark-as-processable
   (interactive "P" gnus-summary-mode)
   (gnus-summary-mark-as-processable n t))
 
+(defun gnus-summary-toggle-mark-as-processable (n)
+  "Toggle the process mark from the next N articles.
+If N is negative, toggle mark backward instead.  The difference between
+N and the actual number of articles with their mark toggled is returned."
+  (interactive "P" gnus-summary-mode)
+  (gnus-summary-mark-as-processable n 'toggle))
+
 (defun gnus-summary-unmark-all-processable ()
   "Remove the process mark from all articles."
   (interactive nil gnus-summary-mode)

-- 
Alex.