emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d6a3b1c: Rename Gnus -unsubscribe-group commands to -toggle-subsc


From: Lars Ingebrigtsen
Subject: master d6a3b1c: Rename Gnus -unsubscribe-group commands to -toggle-subscription
Date: Wed, 28 Jul 2021 14:53:08 -0400 (EDT)

branch: master
commit d6a3b1cd2b175d77bcfb24ac6ae047eb18b1bfcb
Author: dickmao <none>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Rename Gnus -unsubscribe-group commands to -toggle-subscription
    
    * doc/emacs/misc.texi (Gnus Group Buffer): Document change.
    * doc/misc/gnus.texi (Subscription Commands): Document change.
    (Browse Foreign Server): Document change.
    * lisp/gnus/gnus-group.el (gnus-group-mode-map):
    Unsubscribe is not subscribe.
    (gnus-group-sub-map): Unsubscribe is not subscribe.
    (gnus-group-make-menu-bar): Unsubscribe is not subscribe.
    (gnus-group-tool-bar-gnome): Unsubscribe is not subscribe.
    (gnus-group-mode): Unsubscribe is not subscribe.
    (gnus-group-unsubscribe): Refactor.
    (gnus-group-subscribe): Refactor.
    (gnus-group-unsubscribe-current-group): Define obsolete alias.
    (gnus-group-unsubscribe-group): Define obsolete alias.
    (gnus-group-toggle-subscription-at-point): Refactor.
    (gnus-group-set-subscription-at-point): Refactor.
    (gnus-group-toggle-subscription): Refactor.
    (gnus-group-set-subscription): Refactor.
    * lisp/gnus/gnus-srvr.el (gnus-browse-mode-map):
    Unsubscribe is not subscribe.
    (gnus-browse-make-menu-bar): Unsubscribe is not subscribe.
    (gnus-browse-mode): Document the change.
    (gnus-browse-unsubscribe-current-group): Define obsolete alias.
    (gnus-browse-unsubscribe-group): Define obsolete alias.
    (gnus-browse-toggle-subscription-at-point): Unsubscribe is not subscribe.
    (gnus-browse-toggle-subscription): Unsubscribe is not subscribe
    (bug#49759).
---
 doc/emacs/misc.texi     |  7 ++---
 doc/misc/gnus.texi      | 21 ++++++-------
 lisp/gnus/gnus-group.el | 84 ++++++++++++++++++++++++++++++-------------------
 lisp/gnus/gnus-srvr.el  | 21 ++++++++-----
 4 files changed, 77 insertions(+), 56 deletions(-)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index aba98cf..8bf1032 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -163,14 +163,13 @@ List killed groups (@code{gnus-group-list-killed}).
 List zombie groups (@code{gnus-group-list-zombies}).
 
 @kindex u @r{(Gnus Group mode)}
-@findex gnus-group-unsubscribe-current-group
+@findex gnus-group-toggle-subscription
 @cindex subscribe groups
 @cindex unsubscribe groups
 @item u
 Toggle the subscription status of the group
-(@code{gnus-group-unsubscribe-current-group}) on the current line
-(i.e., turn a subscribed group into an unsubscribed group, or vice
-versa).  Invoking this on a killed or zombie group turns it into an
+(@code{gnus-group-toggle-subscription}) on the current line.
+Invoking this on a killed or zombie group turns it into an
 unsubscribed group.
 
 @kindex C-k @r{(Gnus Group mode)}
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 9cdcf39..6dca5b6 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -2318,19 +2318,18 @@ commands listed in @ref{Browse Foreign Server} at hand.
 @itemx u
 @kindex S t @r{(Group)}
 @kindex u @r{(Group)}
-@findex gnus-group-unsubscribe-current-group
-@c @icon{gnus-group-unsubscribe}
-Toggle subscription to the current group
-(@code{gnus-group-unsubscribe-current-group}).
+@findex gnus-group-toggle-subscription
+@c @icon{gnus-group-toggle-subscription}
+Toggle subscription to group under point
+(@code{gnus-group-toggle-subscription}).
 
 @item S s
 @itemx U
 @kindex S s @r{(Group)}
 @kindex U @r{(Group)}
-@findex gnus-group-unsubscribe-group
-Prompt for a group to subscribe, and then subscribe it.  If it was
-subscribed already, unsubscribe it instead
-(@code{gnus-group-unsubscribe-group}).
+@findex gnus-group-toggle-subscription
+Prompt for group, and toggle its subscription.
+(@code{gnus-group-toggle-subscription}).
 
 @item S k
 @itemx C-k
@@ -3736,10 +3735,10 @@ Enter the current group 
(@code{gnus-browse-select-group}).
 
 @item u
 @kindex u @r{(Browse)}
-@findex gnus-browse-unsubscribe-current-group
+@findex gnus-browse-toggle-subscription
 @vindex gnus-browse-subscribe-newsgroup-method
-Unsubscribe to the current group, or, as will be the case here,
-subscribe to it (@code{gnus-browse-unsubscribe-current-group}).  You
+Toggle subscription of the current group
+(@code{gnus-browse-toggle-subscription}).  You
 can affect the way the new group is entered into the Group buffer
 using the variable @code{gnus-browse-subscribe-newsgroup-method}.  See
 @pxref{Subscription Methods} for available options.
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index c8b95d9..ec18b3f 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -589,8 +589,8 @@ simple manner."
   "\M-p" gnus-group-prev-unread-group-same-level
   "," gnus-group-best-unread-group
   "." gnus-group-first-unread-group
-  "u" gnus-group-unsubscribe-current-group
-  "U" gnus-group-unsubscribe-group
+  "u" gnus-group-toggle-subscription-at-point
+  "U" gnus-group-toggle-subscription
   "c" gnus-group-catchup-current
   "C" gnus-group-catchup-current-all
   "\M-c" gnus-group-clear-data
@@ -767,8 +767,8 @@ simple manner."
 
 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
   "l" gnus-group-set-current-level
-  "t" gnus-group-unsubscribe-current-group
-  "s" gnus-group-unsubscribe-group
+  "t" gnus-group-toggle-subscription-at-point
+  "s" gnus-group-toggle-subscription
   "k" gnus-group-kill-group
   "y" gnus-group-yank-group
   "w" gnus-group-kill-region
@@ -814,7 +814,7 @@ simple manner."
        ["Check for new articles " gnus-topic-get-new-news-this-topic
        :included (gnus-topic-mode-p)
        :help "Check for new messages in current group or topic"]
-       ["Toggle subscription" gnus-group-unsubscribe-current-group
+       ["Toggle subscription" gnus-group-toggle-subscription-at-point
        (gnus-group-group-name)]
        ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
        :help "Kill (remove) current group"]
@@ -907,7 +907,7 @@ simple manner."
        ["Execute command" gnus-group-universal-argument
         (or gnus-group-marked (gnus-group-group-name))])
        ("Subscribe"
-       ["Subscribe to a group..." gnus-group-unsubscribe-group t]
+       ["Toggle subscription..." gnus-group-toggle-subscription t]
        ["Kill all newsgroups in region" gnus-group-kill-region
         :active mark-active]
        ["Kill all zombie groups" gnus-group-kill-all-zombies
@@ -1042,7 +1042,7 @@ Pre-defined symbols include `gnus-group-tool-bar-gnome' 
and
     ;; (gnus-group-find-new-groups "???" nil)
     (gnus-group-save-newsrc "save")
     (gnus-group-describe-group "describe")
-    (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
+    (gnus-group-toggle-subscription-at-point "gnus/toggle-subscription")
     (gnus-group-prev-unread-group "left-arrow")
     (gnus-group-next-unread-group "right-arrow")
     (gnus-group-exit "exit")
@@ -1119,7 +1119,7 @@ The group buffer lists (some of) the groups available.  
For instance,
 lists all zombie groups.
 
 Groups that are displayed can be entered with `\\[gnus-group-read-group]'.  To 
subscribe
-to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
+to a group not displayed, type `\\[gnus-group-toggle-subscription]'.
 
 For more in-depth information on this mode, read the manual 
(`\\[gnus-info-find-node]').
 
@@ -3857,61 +3857,79 @@ Uses the process/prefix convention."
 (defun gnus-group-unsubscribe (&optional n)
   "Unsubscribe the current group."
   (interactive "P" gnus-group-mode)
-  (gnus-group-unsubscribe-current-group n 'unsubscribe))
+  (gnus-group-set-subscription-at-point n 'unsubscribe))
 
 (defun gnus-group-subscribe (&optional n)
   "Subscribe the current group."
   (interactive "P" gnus-group-mode)
-  (gnus-group-unsubscribe-current-group n 'subscribe))
+  (gnus-group-set-subscription-at-point n 'subscribe))
 
-(defun gnus-group-unsubscribe-current-group (&optional n do-sub)
+(define-obsolete-function-alias 'gnus-group-unsubscribe-current-group
+  'gnus-group-toggle-subscription-at-point "28.1")
+(define-obsolete-function-alias 'gnus-group-unsubscribe-group
+  'gnus-group-toggle-subscription "28.1")
+
+(defun gnus-group-toggle-subscription-at-point (&optional n)
   "Toggle subscription of the current group.
 If given numerical prefix, toggle the N next groups."
   (interactive "P" gnus-group-mode)
+  (gnus-group-set-subscription-at-point n 'toggle))
+
+(defun gnus-group-set-subscription-at-point (n do-sub)
+  "Set subscription of the current group for next N groups."
   (dolist (group (gnus-group-process-prefix n))
     (gnus-group-remove-mark group)
-    (gnus-group-unsubscribe-group
+    (gnus-group-set-subscription
      group
-     (cond
-      ((eq do-sub 'unsubscribe)
-       gnus-level-default-unsubscribed)
-      ((eq do-sub 'subscribe)
-       gnus-level-default-subscribed)
-      ((<= (gnus-group-group-level) gnus-level-subscribed)
-       gnus-level-default-unsubscribed)
-      (t
-       gnus-level-default-subscribed))
+     (cl-case do-sub
+       (unsubscribe gnus-level-default-unsubscribed)
+       (subscribe gnus-level-default-subscribed)
+       (toggle (if (<= (gnus-group-group-level) gnus-level-subscribed)
+                   gnus-level-default-unsubscribed
+                 gnus-level-default-subscribed))
+       (t (error "Unknown subscription setting %s" do-sub)))
      t)
     (gnus-group-update-group-line))
   (gnus-group-next-group 1))
 
-(defun gnus-group-unsubscribe-group (group &optional level silent)
-  "Toggle subscription to GROUP.
-Killed newsgroups are subscribed.  If SILENT, don't try to update the
-group line."
+(defun gnus-group-toggle-subscription (group &optional silent)
   (interactive (list (gnus-group-completing-read
                      nil nil (gnus-read-active-file-p)))
               gnus-group-mode)
+  (let* ((newsrc (gnus-group-entry group))
+         (level (cond
+                 (newsrc
+                  ;; Toggle subscription flag.
+                  (if (<= (gnus-info-level (nth 1 newsrc))
+                         gnus-level-subscribed)
+                      (1+ gnus-level-subscribed)
+                    gnus-level-default-subscribed))
+                 ((and (stringp group)
+                      (or (not (gnus-read-active-file-p))
+                          (gnus-active group)))
+                  ;; Add new newsgroup.
+                  gnus-level-default-subscribed)
+                 (t 'unsubscribe))))
+    (gnus-group-set-subscription group level silent)))
+
+(defun gnus-group-set-subscription (group level &optional silent)
+  "Set subscription of GROUP to LEVEL.
+Killed newsgroups are subscribed.  If SILENT, don't try to update the
+group line."
   (let ((newsrc (gnus-group-entry group)))
     (cond
      ((string-match "\\`[ \t]*\\'" group)
       (error "Empty group name"))
      (newsrc
-      ;; Toggle subscription flag.
-      (gnus-group-change-level
-       newsrc (or level (if (<= (gnus-info-level (nth 1 newsrc))
-                               gnus-level-subscribed)
-                           (1+ gnus-level-subscribed)
-                         gnus-level-default-subscribed)))
+      (gnus-group-change-level newsrc level)
       (unless silent
        (gnus-group-update-group group)))
      ((and (stringp group)
           (or (not (gnus-read-active-file-p))
               (gnus-active group)))
-      ;; Add new newsgroup.
       (gnus-group-change-level
        group
-       (or level gnus-level-default-subscribed)
+       level
        (or (and (member group gnus-zombie-list)
                gnus-level-zombie)
           gnus-level-killed)
diff --git a/lisp/gnus/gnus-srvr.el b/lisp/gnus/gnus-srvr.el
index f66f842..b316a2e 100644
--- a/lisp/gnus/gnus-srvr.el
+++ b/lisp/gnus/gnus-srvr.el
@@ -716,7 +716,7 @@ claim them."
     "\M-n" gnus-browse-next-group
     "\M-p" gnus-browse-prev-group
     "\r" gnus-browse-select-group
-    "u" gnus-browse-unsubscribe-current-group
+    "u" gnus-browse-toggle-subscription
     "l" gnus-browse-exit
     "L" gnus-browse-exit
     "q" gnus-browse-exit
@@ -735,7 +735,7 @@ claim them."
     (easy-menu-define
      gnus-browse-menu gnus-browse-mode-map ""
      '("Browse"
-       ["Subscribe" gnus-browse-unsubscribe-current-group t]
+       ["Toggle Subscribe" gnus-browse-toggle-subscription t]
        ["Read" gnus-browse-read-group t]
        ["Select" gnus-browse-select-group t]
        ["Describe" gnus-browse-describe-group t]
@@ -881,9 +881,9 @@ All normal editing commands are switched off.
 \\<gnus-browse-mode-map>
 The only things you can do in this buffer is
 
-1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
-The group will be inserted into the group buffer upon exit from this
-buffer.
+1) `\\[gnus-browse-toggle-subscription]' to subscribe or unsubscribe to
+a group.  The group will be inserted into the group buffer upon exit from
+this buffer.
 
 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
 
@@ -933,7 +933,12 @@ If NUMBER, fetch this number of articles."
   (interactive "p" gnus-browse-mode)
   (gnus-browse-next-group (- n)))
 
-(defun gnus-browse-unsubscribe-current-group (arg)
+(define-obsolete-function-alias 'gnus-browse-unsubscribe-current-group
+  'gnus-browse-toggle-subscription-at-point "28.1")
+(define-obsolete-function-alias 'gnus-browse-unsubscribe-group
+  'gnus-browse-toggle-subscription "28.1")
+
+(defun gnus-browse-toggle-subscription-at-point (arg)
   "(Un)subscribe to the next ARG groups.
 The variable `gnus-browse-subscribe-newsgroup-method' determines
 how new groups will be entered into the group buffer."
@@ -944,7 +949,7 @@ how new groups will be entered into the group buffer."
        (arg (abs arg)))
     (while (and (> arg 0)
                (not (eobp))
-               (gnus-browse-unsubscribe-group)
+               (gnus-browse-toggle-subscription)
                (zerop (gnus-browse-next-group ward)))
       (cl-decf arg))
     (gnus-group-position-point)
@@ -976,7 +981,7 @@ doing the deletion."
               gnus-browse-mode)
   (gnus-group-delete-group group force))
 
-(defun gnus-browse-unsubscribe-group ()
+(defun gnus-browse-toggle-subscription ()
   "Toggle subscription of the current group in the browse buffer."
   (let ((sub nil)
        (buffer-read-only nil)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]