From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#29533: Fwd: [Feature Request] ERC: let erc-join-channel support to select channels from history or a defined list Date: Mon, 18 May 2020 17:15:33 -0700 Message-ID: References: <87eez3kebf.fsf@gnus.org> <87v9lbykbp.fsf@stefankangas.se> <87tv0veuyh.fsf@gmail.com> <87eerzyhbi.fsf@stefankangas.se> <87r1vpogto.fsf@gmail.com> <87ftc4ukv1.fsf@gmail.com> <8736839odz.fsf@gmail.com> <87lflpcu2x.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="87359"; mail-complaints-to="usenet@ciao.gmane.io" Cc: stardiviner , Lars Ingebrigtsen , 29533@debbugs.gnu.org To: Amin Bandali Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 19 02:16:11 2020 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 1japvX-000MbS-3T for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 May 2020 02:16:11 +0200 Original-Received: from localhost ([::1]:56374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1japvV-0007JO-IU for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 May 2020 20:16:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1japvO-0007J9-Nw for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 20:16:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1japvO-0007Lb-Ez for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 20:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1japvO-0005RM-A6 for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 20:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 May 2020 00:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29533 X-GNU-PR-Package: emacs Original-Received: via spool by 29533-submit@debbugs.gnu.org id=B29533.158984734120881 (code B ref 29533); Tue, 19 May 2020 00:16:02 +0000 Original-Received: (at 29533) by debbugs.gnu.org; 19 May 2020 00:15:41 +0000 Original-Received: from localhost ([127.0.0.1]:48615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1japv2-0005Qj-ID for submit@debbugs.gnu.org; Mon, 18 May 2020 20:15:40 -0400 Original-Received: from mail-qk1-f181.google.com ([209.85.222.181]:42640) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1japv1-0005QJ-1G for 29533@debbugs.gnu.org; Mon, 18 May 2020 20:15:39 -0400 Original-Received: by mail-qk1-f181.google.com with SMTP id s1so12586394qkf.9 for <29533@debbugs.gnu.org>; Mon, 18 May 2020 17:15:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=LfEMiRYl4RN0nDoW7fcaneAZPTnbDRHnAboLCaEd794=; b=RkDQkbV9ovnr32KNRNoSJ8AtetVJSlo03ZcBAuHw5hkysUVJXkRyk3dNNm+aQhPUPm FcuB2G/MyHQmPCMzCnYEyfyGhpoDYqu8SwTHf5Wxr5v1qNnl0leR7zdvLOC2ihtHVfWj Vc/qBfuovos+8l+lLcstjvAQzB+kbb8yMoi6Af9rFWkdNbCx3P1fuXrRFKxGsWrSczQH SQCYvxC0MOcvP209UxSQTjFEQw7KG96/vpgzIWUiSvhafyeQdgDDB3KvQCIo2phDLz68 v+mLZ3EjHdnj8H0+DaGDMe63nQGG/nK4VwjjViXoSX2X/EyQQLchvaNc20RJlkg8LciY yyxQ== X-Gm-Message-State: AOAM531bVZM4YhqUMqFVu/m1dG4SyYiF8dIrTrXXTNnj+NU5pI/LNQZM VjrdbcByJtw9Y66uVC0uahEYCuDlWqQcR2yvk3HomA== X-Google-Smtp-Source: ABdhPJw2KmKE4olNPQwO1ntUVVzcTokq6OuTz+Kj8IhMhW5ssRSzE8U2JkTBS7Clckv7qa0Hat9J3MgS+BVoHfFoVIM= X-Received: by 2002:a25:ad4c:: with SMTP id l12mr29888754ybe.389.1589847333674; Mon, 18 May 2020 17:15:33 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 18 May 2020 17:15:33 -0700 In-Reply-To: <87lflpcu2x.fsf@gmail.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:180566 Archived-At: Hi Amin, stardiviner writes: > At last, I attached my generated commit in attachment. Could you please help review the below patch? I don't really use ERC. Thanks in advance. Best regards, Stefan Kangas > From 26f73fe065196ab8759f6c7f046587e47672ad47 Mon Sep 17 00:00:00 2001 > From: stardiviner > Date: Mon, 18 May 2020 20:16:21 +0800 > Subject: [PATCH] Join channel smartly from alist of stored channels > > * lisp/erc/erc.el (erc-mode-map): Add an option to store your frequently > joined channels. And replace original `erc-join-channel' with > `erc-join-channel-select'. > --- > lisp/erc/erc.el | 41 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 40 insertions(+), 1 deletion(-) > > diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el > index cfde84e19a..be59b4203f 100644 > --- a/lisp/erc/erc.el > +++ b/lisp/erc/erc.el > @@ -1161,7 +1161,7 @@ erc-mode-map > (define-key map "\C-c\C-e" 'erc-toggle-ctcp-autoresponse) > (define-key map "\C-c\C-f" 'erc-toggle-flood-control) > (define-key map "\C-c\C-i" 'erc-invite-only-mode) > - (define-key map "\C-c\C-j" 'erc-join-channel) > + (define-key map "\C-c\C-j" 'erc-join-channel-select) > (define-key map "\C-c\C-n" 'erc-channel-names) > (define-key map "\C-c\C-o" 'erc-get-channel-mode-from-keypress) > (define-key map "\C-c\C-p" 'erc-part-from-channel) > @@ -3993,6 +3993,34 @@ erc-input-action > (if (not (string-match "^\\s-*$" action)) > (erc-send-action (erc-default-target) action)))) > > +(defcustom erc-join-channels-alist nil > + "Alist of channels to select when you join channels. > + > +Every element in the alist has the form (SERVER . CHANNELS). > +SERVER is a regexp matching the server, and channels is the > +list of channels to join. > + > +If the channel(s) require channel keys for joining, the passwords > +are found via auth-source. For instance, if you use ~/.authinfo > +as your auth-source backend, then put something like the > +following in that file: > + > +machine irc.example.net login \"#fsf\" password sEcReT > + > +Customize this variable to set the value for your first connect. > +Once you are connected and join and part channels, this alist > +keeps track of what channels you are on, and will join them > +again when you get disconnected. When you restart Emacs, however, > +those changes are lost, and the customization you saved the last > +time is used again." > + :group 'erc-join > + :type '(repeat (cons :tag "Server" > + (regexp :tag "Name") > + (repeat :tag "Channels" > + (string :tag "Name"))))) > + > +(setq erc-join-channels-alist '(("*.freenode.net" "#emacs" "#org-mode"))) > + > (defun erc-join-channel (channel &optional key) > "Join CHANNEL. > > @@ -4008,6 +4036,17 @@ erc-join-channel > (read-from-minibuffer "Channel key (RET for none): " nil)))) > (erc-cmd-JOIN channel (when (>= (length key) 1) key))) > > +(defun erc-join-channel-select () > + "Select a channel to join from alist of channels to." > + (interactive) > + (erc-join-channel > + (completing-read > + "Select a channel: " > + (cdr (assoc > + (completing-read "Select a server: " > + (mapcar 'car erc-join-channels-alist)) > + erc-join-channels-alist))))) > + > (defun erc-part-from-channel (reason) > "Part from the current channel and prompt for a REASON." > (interactive > -- > 2.26.2