From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alex Bochannek Newsgroups: gmane.emacs.bugs Subject: bug#48683: 28.0.50; [PATCH] Feature suggestion gnus-summary-toggle-mark-as-processable Date: Tue, 01 Jun 2021 13:45:32 -0700 Message-ID: References: <87cztb4uzs.fsf@gnus.org> <878s3ywadg.fsf@gnus.org> <878s3uf6ij.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2197"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: 48683@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 01 22:46:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1loBH8-0000Lp-MT for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Jun 2021 22:46:10 +0200 Original-Received: from localhost ([::1]:43026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loBH7-00038v-LI for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Jun 2021 16:46:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loBH0-00038m-4t for bug-gnu-emacs@gnu.org; Tue, 01 Jun 2021 16:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loBGz-0006Yf-T8 for bug-gnu-emacs@gnu.org; Tue, 01 Jun 2021 16:46:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1loBGz-0007cb-Py for bug-gnu-emacs@gnu.org; Tue, 01 Jun 2021 16:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Bochannek Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Jun 2021 20:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48683 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 48683-submit@debbugs.gnu.org id=B48683.162258034129269 (code B ref 48683); Tue, 01 Jun 2021 20:46:01 +0000 Original-Received: (at 48683) by debbugs.gnu.org; 1 Jun 2021 20:45:41 +0000 Original-Received: from localhost ([127.0.0.1]:37997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1loBGe-0007c1-VJ for submit@debbugs.gnu.org; Tue, 01 Jun 2021 16:45:41 -0400 Original-Received: from ns.lapseofthought.com ([50.0.39.240]:54621 helo=mail.lapseofthought.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1loBGa-0007bq-Sh for 48683@debbugs.gnu.org; Tue, 01 Jun 2021 16:45:40 -0400 Original-Received: from awb-mbp.local (unknown [IPv6:2601:646:4200:b470:c5ce:264e:3af5:9738]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lapseofthought.com (Postfix) with ESMTPSA id 4Fvkgy1x7cz3pdjV; Tue, 1 Jun 2021 13:45:34 -0700 (PDT) In-Reply-To: <878s3uf6ij.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 01 Jun 2021 08:23:00 +0200") Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207804 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Alex Bochannek writes: > >>> It seems like many people would prefer to have the `#' command be a >>> toggle. Perhaps we should just add a user option to have `#' toggle or >>> not? (Defaulting to "not toggle" for backwards compatibility.) >> >> How about something like this? > > Looks good. Some small comments: > >> +(defcustom gnus-summary-process-mark-toggle nil > > Perhaps this should be gnus-process-mark-toggle and also work in the > Group buffer? See below. I tried to make sure that only `#' changes behavior and not `M-#' (this is why there is a `no-toggle' variable for some of the functions.) Have a look and let me know what you think. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 7d6fa4cb5c..ebb1df5552 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -2583,7 +2583,9 @@ Marking Groups @itemx M m @kindex M m @r{(Group)} @findex gnus-group-mark-group -Set the mark on the current group (@code{gnus-group-mark-group}). +Set the mark on the current group (@code{gnus-group-mark-group}).@* +If @code{gnus-process-mark-toggle} is non-nil, toggle the +existing process mark for the current group. @item M-# @kindex M-# @r{(Group)} @@ -4043,7 +4045,9 @@ Topic Commands @findex gnus-topic-mark-topic Mark all groups in the current topic with the process mark (@code{gnus-topic-mark-topic}). This command works recursively on -sub-topics unless given a prefix. +sub-topics unless given a prefix.@* +If @code{gnus-process-mark-toggle} is non-nil, toggle the +existing process mark for the current topic. @item T M-# @kindex T M-# @r{(Topic)} @@ -6618,13 +6622,15 @@ Setting Process Marks @kindex M P p @r{(Summary)} @findex gnus-summary-mark-as-processable Mark the current article with the process mark -(@code{gnus-summary-mark-as-processable}). -@findex gnus-summary-unmark-as-processable +(@code{gnus-summary-mark-as-processable}).@* +If @code{gnus-process-mark-toggle} is non-nil, toggle the +existing process mark for the current article. @item M P u @itemx M-# @kindex M P u @r{(Summary)} @kindex M-# @r{(Summary)} +@findex gnus-summary-unmark-as-processable Remove the process mark, if any, from the current article (@code{gnus-summary-unmark-as-processable}). @@ -10569,6 +10575,8 @@ Pick and Read it selects just the article. If given a numerical prefix, go to that thread or article and pick it. (The line number is normally displayed at the beginning of the summary pick lines.) +If @code{gnus-process-mark-toggle} is non-nil, this key will unpick an +already picked article. @item @key{SPC} @kindex SPC @r{(Pick)} diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index 8c62c9424d..06d1313d37 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -894,14 +894,14 @@ gnus-group-make-menu-bar ["Sort by real name" gnus-group-sort-selected-groups-by-real-name (not (gnus-topic-mode-p))]) ("Mark" - ["Mark group" gnus-group-mark-group + ["Set/Toggle mark" gnus-group-mark-group (and (gnus-group-group-name) (not (memq (gnus-group-group-name) gnus-group-marked)))] - ["Unmark group" gnus-group-unmark-group + ["Remove mark" gnus-group-unmark-group (and (gnus-group-group-name) (memq (gnus-group-group-name) gnus-group-marked))] - ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked] - ["Mark regexp..." gnus-group-mark-regexp t] + ["Remove all marks" gnus-group-unmark-all-groups gnus-group-marked] + ["Mark by regexp..." gnus-group-mark-regexp t] ["Mark region" gnus-group-mark-region :active mark-active] ["Mark buffer" gnus-group-mark-buffer t] ["Execute command" gnus-group-universal-argument @@ -1865,7 +1865,7 @@ gnus-group-mark-line-p (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2)) (eq (char-after) gnus-process-mark))) -(defun gnus-group-mark-group (n &optional unmark no-advance) +(defun gnus-group-mark-group (n &optional unmark no-advance no-toggle) "Mark the current group." (interactive "p" gnus-group-mode) (let ((buffer-read-only nil) @@ -1877,23 +1877,33 @@ gnus-group-mark-group (beginning-of-line) (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2)) (delete-char 1) - (if unmark - (progn - (setq gnus-group-marked (delete group gnus-group-marked)) - (insert-char ?\s 1 t)) - (setq gnus-group-marked - (cons group (delete group gnus-group-marked))) - (insert-char gnus-process-mark 1 t))) + (if (and gnus-process-mark-toggle (not no-toggle)) + (if (memq group gnus-group-marked) + (gnus-group-mark-update group t) + (gnus-group-mark-update group)) + (gnus-group-mark-update group unmark))) (unless no-advance (gnus-group-next-group 1)) (cl-decf n)) (gnus-group-position-point) n)) +(defun gnus-group-mark-update (n &optional unmark) + "Set the process mark on current group and update the group line." + (if unmark + (progn + (setq gnus-group-marked + (delete n gnus-group-marked)) + (insert-char ?\s 1 t)) + (progn + (setq gnus-group-marked + (cons n (delete n gnus-group-marked))) + (insert-char gnus-process-mark 1 t)))) + (defun gnus-group-unmark-group (n) "Remove the mark from the current group." (interactive "p" gnus-group-mode) - (gnus-group-mark-group n 'unmark) + (gnus-group-mark-group n 'unmark nil t) (gnus-group-position-point)) (defun gnus-group-unmark-all-groups () @@ -1910,7 +1920,7 @@ gnus-group-mark-region (let ((num (count-lines beg end))) (save-excursion (goto-char beg) - (- num (gnus-group-mark-group num unmark))))) + (- num (gnus-group-mark-group num unmark nil t))))) (defun gnus-group-mark-buffer (&optional unmark) "Mark all groups in the buffer. @@ -1935,7 +1945,7 @@ gnus-group-remove-mark Return nil if the group isn't displayed." (if (gnus-group-goto-group group nil test-marked) (save-excursion - (gnus-group-mark-group 1 'unmark t) + (gnus-group-mark-group 1 'unmark t t) t) (setq gnus-group-marked (delete group gnus-group-marked)) @@ -1945,7 +1955,7 @@ gnus-group-set-mark "Set the process mark on GROUP." (if (gnus-group-goto-group group) (save-excursion - (gnus-group-mark-group 1 nil t)) + (gnus-group-mark-group 1 nil t t)) (setq gnus-group-marked (cons group (delete group gnus-group-marked))))) (defun gnus-group-universal-argument (arg &optional _groups func) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index aa4c753287..48794ceb3f 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -2774,7 +2774,7 @@ gnus-summary-make-menu-bar ["Hide marked" gnus-summary-limit-exclude-marks t] ["Show expunged" gnus-summary-limit-include-expunged t]) ("Process Mark" - ["Set mark" gnus-summary-mark-as-processable t] + ["Set/Toggle mark" gnus-summary-mark-as-processable t] ["Remove mark" gnus-summary-unmark-as-processable t] ["Remove all marks" gnus-summary-unmark-all-processable t] ["Invert marks" gnus-uu-invert-processable t] @@ -10951,10 +10951,14 @@ 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))) + (if unmark + (gnus-summary-remove-process-mark article) + (if gnus-process-mark-toggle + (if (memq article gnus-newsgroup-processable) + (gnus-summary-remove-process-mark article) + (gnus-summary-set-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) diff --git a/lisp/gnus/gnus-topic.el b/lisp/gnus/gnus-topic.el index b3d17bc03f..c0484622f4 100644 --- a/lisp/gnus/gnus-topic.el +++ b/lisp/gnus/gnus-topic.el @@ -1112,7 +1112,7 @@ gnus-topic-make-menu-bar ["Delete" gnus-topic-delete t] ["Rename..." gnus-topic-rename t] ["Create..." gnus-topic-create-topic t] - ["Mark" gnus-topic-mark-topic t] + ["Set/Toggle mark" gnus-topic-mark-topic t] ["Indent" gnus-topic-indent t] ["Sort" gnus-topic-sort-topics t] ["Previous topic" gnus-topic-goto-previous-topic t] @@ -1436,7 +1436,7 @@ gnus-topic-show-topic (setcar (cdr (cadr topic)) 'visible) (gnus-group-list-groups))))) -(defun gnus-topic-mark-topic (topic &optional unmark non-recursive) +(defun gnus-topic-mark-topic (topic &optional unmark non-recursive no-toggle) "Mark all groups in the TOPIC with the process mark. If NON-RECURSIVE (which is the prefix) is t, don't mark its subtopics." (interactive @@ -1450,8 +1450,13 @@ gnus-topic-mark-topic (let ((groups (gnus-topic-find-groups topic gnus-level-killed t nil (not non-recursive)))) (while groups - (funcall (if unmark 'gnus-group-remove-mark 'gnus-group-set-mark) - (gnus-info-group (nth 1 (pop groups))))))))) + (let ((group (gnus-info-group (nth 1 (pop groups))))) + (if (and gnus-process-mark-toggle (not no-toggle)) + (if (memq group gnus-group-marked) + (gnus-group-remove-mark group ) + (gnus-group-set-mark group)) + (if unmark (gnus-group-remove-mark group) + (gnus-group-set-mark group))))))))) (defun gnus-topic-unmark-topic (topic &optional _dummy non-recursive) "Remove the process mark from all groups in the TOPIC. @@ -1462,7 +1467,7 @@ gnus-topic-unmark-topic gnus-topic-mode) (if (not topic) (call-interactively 'gnus-group-unmark-group) - (gnus-topic-mark-topic topic t non-recursive))) + (gnus-topic-mark-topic topic t non-recursive t))) (defun gnus-topic-get-new-news-this-topic (&optional n) "Check for new news in the current topic." diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 7de1cd1ddb..21b5f31c14 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el @@ -1183,6 +1183,14 @@ gnus-process-mark :group 'gnus-summary-marks :type 'character) +(defcustom gnus-process-mark-toggle nil + "If non-nil the process mark command toggles the process mark." + :version "28.1" + :group 'gnus-summary + :group 'gnus-group-various + :group 'gnus-group-topic + :type 'boolean) + (defcustom gnus-large-newsgroup 200 "The number of articles which indicates a large newsgroup. If the number of articles in a newsgroup is greater than this value, --=-=-= Content-Type: text/plain -- Alex. --=-=-=--