This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+chat/rcirc/local/helm-rcirc/helm-rcirc.el
syl20bnr 9d0558992c layers directory: create new categories
+chat
+checkers
+emacs
+intl
+os
+pair-programming
+tags
+theme
+web-services
2016-03-23 21:39:43 -04:00

39 lines
1.5 KiB
EmacsLisp

(require 'rcirc)
(defun helm-rcirc-auto-join-channels-alist ()
"Return an alist where key is a server and value is a list of defined
channels to auto join."
(mapcar (lambda (server)
(cons (car server) (plist-get (cdr server) :channels)))
rcirc-server-alist)
)
(defun helm-rcirc-auto-join-channels-source (entry)
"Construct the Helm source given an ENTRY.
ENTRY is a key value pair where key is the server and value is a list of
channels."
(let ((server (car entry))
(chans (cdr entry)))
(list (cons 'name (format "Server: %s" (car entry)))
(cons 'candidates (mapcar (lambda (chan)
(cons chan (cons server chan))) chans))
(cons 'action 'helm-rcirc-open-channel-buffer))))
(defun helm-rcirc-open-channel-buffer (selected-value)
"Open the buffer corresponding to SELECTED-VALUE if any.
SELECTED-VALUE is a key value pair where key is the server and value is the
channel name."
(let ((buf (format "%s@%s" (cdr selected-value) (car selected-value))))
(if (bufferp (get-buffer buf))
(switch-to-buffer buf)
(message (format "Cannot find buffer %s" buf)))))
;;;###autoload
(defun helm-rcirc-auto-join-channels ()
"rcirc auto join channels selection with helm interface."
(interactive)
(helm :buffer "*helm: Auto Join Channels (rcirc)*"
:sources (mapcar 'helm-rcirc-auto-join-channels-source
(helm-rcirc-auto-join-channels-alist))))