doomemacs/modules/app/irc/autoload/ivy.el
Henrik Lissner ad6a3d0f33
refactor: deprecate featurep! for modulep!
featurep! will be renamed modulep! in the future, so it's been
deprecated. They have identical interfaces, and can be replaced without
issue.

featurep! was never quite the right name for this macro. It implied that
it had some connection to featurep, which it doesn't (only that it was
similar in purpose; still, Doom modules are not features). To undo such
implications and be consistent with its namespace (and since we're
heading into a storm of breaking changes with the v3 release anyway),
now was the best opportunity to begin the transition.
2022-08-14 20:43:35 +02:00

30 lines
1.5 KiB
EmacsLisp

;;; app/irc/autoload/ivy.el -*- lexical-binding: t; -*-
;;;###if (modulep! :completion ivy)
;;;###autoload
(defun +irc/ivy-jump-to-channel (&optional this-server)
"Jump to an open channel or server buffer with ivy. If THIS-SERVER (universal
argument) is non-nil only show channels in current server."
(interactive "P")
(if (not (circe-server-buffers))
(message "No circe buffers available")
(when (and this-server (not circe-server-buffer))
(setq this-server nil))
(ivy-read (format "Jump to%s: " (if this-server (format " (%s)" (buffer-name circe-server-buffer)) ""))
(cl-loop with servers = (if this-server (list circe-server-buffer) (circe-server-buffers))
with current-buffer = (current-buffer)
for server in servers
collect (buffer-name server)
nconc
(with-current-buffer server
(cl-loop for buf in (circe-server-chat-buffers)
unless (eq buf current-buffer)
collect (format " %s" (buffer-name buf)))))
:action #'+irc--ivy-switch-to-buffer-action
:preselect (buffer-name (current-buffer))
:keymap ivy-switch-buffer-map
:caller '+irc/ivy-jump-to-channel)))
(defun +irc--ivy-switch-to-buffer-action (buffer)
(when (stringp buffer)
(ivy--switch-buffer-action (string-trim-left buffer))))