From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: stardiviner 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: Sat, 2 Dec 2017 13:44:17 +0800 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------C87371CEAAB4DF562043A4B2" X-Trace: blaine.gmane.org 1512194540 12744 195.159.176.226 (2 Dec 2017 06:02:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 2 Dec 2017 06:02:20 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 To: 29533@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 02 07:02:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eL0sJ-0002aJ-44 for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Dec 2017 07:02:07 +0100 Original-Received: from localhost ([::1]:34481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eL0sQ-00032y-Hp for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Dec 2017 01:02:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eL0sI-0002u4-RN for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 01:02:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eL0sE-0000k1-Qc for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 01:02:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eL0sE-0000jt-Mg for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 01:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eL0sE-0003rW-8f for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 01:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: stardiviner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Dec 2017 06:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 29533 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.151219447914788 (code B ref -1); Sat, 02 Dec 2017 06:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Dec 2017 06:01:19 +0000 Original-Received: from localhost ([127.0.0.1]:40892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eL0rV-0003qP-RV for submit@debbugs.gnu.org; Sat, 02 Dec 2017 01:01:19 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eL0bM-0003Sj-6u for submit@debbugs.gnu.org; Sat, 02 Dec 2017 00:44:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eL0bF-0005Sk-LB for submit@debbugs.gnu.org; Sat, 02 Dec 2017 00:44:31 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:47638) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eL0bF-0005Sg-Hm for submit@debbugs.gnu.org; Sat, 02 Dec 2017 00:44:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eL0bD-0005sF-KP for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 00:44:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eL0b8-0005QN-UJ for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 00:44:27 -0500 Original-Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:39755) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eL0b8-0005Q3-MD for bug-gnu-emacs@gnu.org; Sat, 02 Dec 2017 00:44:22 -0500 Original-Received: by mail-pl0-x243.google.com with SMTP id bi12so7455380plb.6 for ; Fri, 01 Dec 2017 21:44:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:references:to:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=37KRtL7ob4jFKYhaFbB8BZtrm7Yyyh+JQE/44jLDrok=; b=EpvdjCpMv0IuM/RoaR0c9UORMYn5VAP+O+oZ8oBgndKnPZ6XaRRZcUOTsR0XjQvmay tnQrnrlNqAQbRI4DHhPonNX1R9RTFfVro3hTHRlr1Tj6VTTF0x+ifq+FWP3zrkGW/bJ4 qZ9MGPJCN+/gFkwabRnkXhJtaeNTJSe3KhDASe59FkJ+fBf4no19pWX0kyx7p0XvMqzW I+iLjqlBBMuWZUyV0TV8jEv/s4L8lS3PAP+EINbi3IeeOKKn/WXjUjJysn2WDPyhb/E9 HJcFU06cL1QLA1+dLdospEtX8yozBJBkr1AYjkt0zPn3M1lLvSYI9vdatx+QZAZ7TlRA 2nzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:references:to:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=37KRtL7ob4jFKYhaFbB8BZtrm7Yyyh+JQE/44jLDrok=; b=BE3kofCO2hDMtmCszbf2qTiO/5327h6te/bC/syZKWtk+nuF8OEHG+5Y+P3FkzHkYy SfXRsEoUbVBME1t4BUIlclfRSz0OVcOLXHigorqypbglnkErSpohA4VQQvTyHVGRtALr bSbX10G9N4ZB2QwTwuWcgbOdJigX1lspiAxi5SuSWJ0h+PYde0TjSQ0JzSgJeDT/AZLj AUIk27LDVvC7UJUZYp4mnIKk/hfVrOAr4SQQ37m22g5WX2Kt3pO1LZHf1RqZk6un1miP baIh0doP4ebrF0MgOhoCO+/PeDXSsqEbO47FpeHtXg40Fvc84sBpKOXI3E4FEJu0EAWi Cisg== X-Gm-Message-State: AJaThX4MYJt686P5040qmDJlmV3CZSzc7AV4h5O0vehlaXmkjF0JahTy VW2RjLlT5b64H06GZqRYKbQQDY0= X-Google-Smtp-Source: AGs4zMbbJyOtrebc8/flZFfjh3yA7t3+WwvtSBtqx0C3zfpLLVZEvYNAWS0m+2hR6rWR+/UbLbrEVQ== X-Received: by 10.84.234.9 with SMTP id m9mr8469378plk.436.1512193461401; Fri, 01 Dec 2017 21:44:21 -0800 (PST) Original-Received: from [0.0.0.0] ([119.28.89.243]) by smtp.gmail.com with ESMTPSA id g77sm14970815pfd.75.2017.12.01.21.44.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Dec 2017 21:44:19 -0800 (PST) X-Forwarded-Message-Id: In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Sat, 02 Dec 2017 01:01:16 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140612 Archived-At: This is a multi-part message in MIME format. --------------C87371CEAAB4DF562043A4B2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit -------- Forwarded Message -------- Subject: [Feature Request] ERC: let erc-join-channel support to select channels from history or a defined list Date: Fri, 1 Dec 2017 18:54:26 +0800 From: stardiviner To: emacs-help let erc-join-channel support to select channels from history or a defined list. I have a code prototype: #+begin_src emacs-lisp (defun erc-join-channel (channel &optional key)   "Join CHANNEL. If `point' is at the beginning of a channel name, use that as default."   (interactive    (list     (let ((chnl (if (looking-at "\\([&#+!][^ \n]+\\)") (match-string 1) ""))           (table (when (erc-server-buffer-live-p)                    (set-buffer (process-buffer erc-server-process))                    erc-channel-list)))       (completing-read "Join channel: " table nil nil nil nil chnl))     (when (or current-prefix-arg erc-prompt-for-channel-key)       (read-from-minibuffer "Channel key (RET for none): " nil))))   (erc-cmd-JOIN channel (when (>= (length key) 1) key))) #+end_src #+begin_src emacs-lisp (defcustom erc-join-channels-frequently-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-frequently-alist       '((".*\\.freenode.net" ; "freenode.net"          "#emacs"          "#org-mode"          "#lisp"          "#clojure"          "#clojure-beginners"          "#archlinux"          "#swift-lang"          "#docker"          "#hackerrank"          ))) (defun erc-join-channels-frequently-select (channel &optional key)   "Select a channel to join from alist of channels to."   (interactive "P")   (completing-read "Select a channel to join: "                    (cdr (car                          erc-join-channels-frequently-alist)))   ;; TODO match IRC server for the selected channel.   ) ;; FIXME: (advice-add 'erc-join-channels-frequently-select :before 'erc-join-channel) #+end_src With this feature, user can avoid typing, and don't need to remember the channel name, and use the join channels history. --------------C87371CEAAB4DF562043A4B2 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit




-------- Forwarded Message --------
Subject: [Feature Request] ERC: let erc-join-channel support to select channels from history or a defined list
Date: Fri, 1 Dec 2017 18:54:26 +0800
From: stardiviner <numbchild@gmail.com>
To: emacs-help <help-gnu-emacs@gnu.org>


let erc-join-channel support to select channels from history or a
defined list.


I have a code prototype:

#+begin_src emacs-lisp
(defun erc-join-channel (channel &optional key)
  "Join CHANNEL.

If `point' is at the beginning of a channel name, use that as default."
  (interactive
   (list
    (let ((chnl (if (looking-at "\\([&#+!][^ \n]+\\)") (match-string 1) ""))
          (table (when (erc-server-buffer-live-p)
                   (set-buffer (process-buffer erc-server-process))
                   erc-channel-list)))
      (completing-read "Join channel: " table nil nil nil nil chnl))
    (when (or current-prefix-arg erc-prompt-for-channel-key)
      (read-from-minibuffer "Channel key (RET for none): " nil))))
  (erc-cmd-JOIN channel (when (>= (length key) 1) key)))
#+end_src

#+begin_src emacs-lisp
(defcustom erc-join-channels-frequently-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-frequently-alist
      '((".*\\.freenode.net" ; "freenode.net"
         "#emacs"
         "#org-mode"
         "#lisp"
         "#clojure"
         "#clojure-beginners"
         "#archlinux"
         "#swift-lang"
         "#docker"
         "#hackerrank"
         )))

(defun erc-join-channels-frequently-select (channel &optional key)
  "Select a channel to join from alist of channels to."
  (interactive "P")
  (completing-read "Select a channel to join: "
                   (cdr (car
                         erc-join-channels-frequently-alist)))
  ;; TODO match IRC server for the selected channel.
  )

;; FIXME:
(advice-add 'erc-join-channels-frequently-select :before 'erc-join-channel)
#+end_src


With this feature, user can avoid typing, and don't need to remember the
channel name, and use the join channels history.

--------------C87371CEAAB4DF562043A4B2--