From: stardiviner <numbchild@gmail.com>
To: emacs-help <help-gnu-emacs@gnu.org>
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 [thread overview]
Message-ID: <e987db8a-fcf6-da73-d914-1deb358b08d3@gmail.com> (raw)
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.
next reply other threads:[~2017-12-01 10:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 10:54 stardiviner [this message]
2017-12-01 18:28 ` [Feature Request] ERC: let erc-join-channel support to select channels from history or a defined list Drew Adams
2017-12-01 21:53 ` Emanuel Berg
2017-12-01 19:18 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e987db8a-fcf6-da73-d914-1deb358b08d3@gmail.com \
--to=numbchild@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).