summaryrefslogtreecommitdiff
path: root/lisp/gnus
diff options
context:
space:
mode:
authorAlex Bochannek <alex@bochannek.com>2021-06-02 07:41:25 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-06-02 07:41:25 +0200
commit16793dc35a5be4d05e3fa42ea8cf6aa1e67f1dc9 (patch)
tree3eece5ba4f25fe8ca154d7a62a7a8905af6a4330 /lisp/gnus
parent4784b6eb9a8d0d54b56db0805732ffc5e71332d3 (diff)
downloademacs-16793dc35a5be4d05e3fa42ea8cf6aa1e67f1dc9.tar.gz
emacs-16793dc35a5be4d05e3fa42ea8cf6aa1e67f1dc9.tar.bz2
emacs-16793dc35a5be4d05e3fa42ea8cf6aa1e67f1dc9.zip
Add new user option to Gnus to allow `#' to toggle
* doc/misc/gnus.texi (Marking Groups, Setting Process Marks): Mention the new variable. * lisp/gnus/gnus-group.el (gnus-group-make-menu-bar): Update menu. (gnus-group-mark-group): Support the variable. (gnus-group-mark-update): New command. (gnus-group-unmark-group, gnus-group-mark-region): Pass in new parameter. * lisp/gnus/gnus-sum.el (gnus-summary-make-menu-bar): Update menu. (gnus-summary-mark-as-processable): Use the variable. * lisp/gnus/gnus-topic.el (gnus-topic-mark-topic): (bug#48683). * lisp/gnus/gnus-topic.el (gnus-topic-mark-topic): Use the variable. * lisp/gnus/gnus.el (gnus-process-mark-toggle): New user option.
Diffstat (limited to 'lisp/gnus')
-rw-r--r--lisp/gnus/gnus-group.el42
-rw-r--r--lisp/gnus/gnus-sum.el14
-rw-r--r--lisp/gnus/gnus-topic.el15
-rw-r--r--lisp/gnus/gnus.el8
4 files changed, 53 insertions, 26 deletions
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index 8c62c9424de..06d1313d379 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -894,14 +894,14 @@ simple manner."
["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 @@ If FIRST-TOO, the current line is also eligible as a target."
(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 @@ If FIRST-TOO, the current line is also eligible as a target."
(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 @@ If UNMARK, remove the mark instead."
(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 @@ If UNMARK, remove the mark instead."
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 @@ Return nil if the group isn't displayed."
"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 aa4c7532878..48794ceb3fe 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -2774,7 +2774,7 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
["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 @@ number of articles marked is returned."
(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 b3d17bc03fb..c0484622f40 100644
--- a/lisp/gnus/gnus-topic.el
+++ b/lisp/gnus/gnus-topic.el
@@ -1112,7 +1112,7 @@ articles in the topic and its subtopics."
["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 @@ If PERMANENT, make it stay shown in subsequent sessions as well."
(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 @@ If NON-RECURSIVE (which is the prefix) is t, don't mark its subtopics."
(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 @@ If NON-RECURSIVE (which is the prefix) is t, don't unmark its subtopics."
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 7de1cd1ddb1..21b5f31c141 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -1183,6 +1183,14 @@ newsgroups."
: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,