From 693eb3c9a42690d11ba360a8308b85523acaf06e Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Sat, 8 May 2021 22:50:58 +0300 Subject: [PATCH] selectrum: add +irc/selectrum-jump-to-channel --- modules/app/irc/autoload/irc.el | 5 +++-- modules/app/irc/autoload/selectrum.el | 25 +++++++++++++++++++++++++ modules/app/irc/config.el | 4 ++++ modules/completion/selectrum/TODO.org | 1 - 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 modules/app/irc/autoload/selectrum.el diff --git a/modules/app/irc/autoload/irc.el b/modules/app/irc/autoload/irc.el index fac63139f..85f9f36c7 100644 --- a/modules/app/irc/autoload/irc.el +++ b/modules/app/irc/autoload/irc.el @@ -68,8 +68,9 @@ workspace for it." argument) is non-nil only show channels in current server." (interactive "P") (call-interactively - (cond ((featurep! :completion ivy) #'+irc/ivy-jump-to-channel) - ((user-error "No jump-to-channel backend is enabled. Enable ivy!"))))) + (cond ((featurep! :completion ivy) #'+irc/ivy-jump-to-channel) + ((featurep! :completion selectrum) #'+irc/selectrum-jump-to-channel) + ((user-error "No jump-to-channel backend is enabled. Enable selectrum or ivy!"))))) ;;;###autoload (defun +irc/tracking-next-buffer () diff --git a/modules/app/irc/autoload/selectrum.el b/modules/app/irc/autoload/selectrum.el new file mode 100644 index 000000000..5bd5532a2 --- /dev/null +++ b/modules/app/irc/autoload/selectrum.el @@ -0,0 +1,25 @@ +;;; app/irc/autoload/selectrum.el -*- lexical-binding: t; -*- +;;;###if (featurep! :completion selectrum) + +;;;###autoload +(defun +irc/selectrum-jump-to-channel (&optional this-server) + "Jump to an open channel or server buffer with selectrum. 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)) + (when-let + ((buffer (completing-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 (buffer-name buf))))))) + (switch-to-buffer buffer)))) diff --git a/modules/app/irc/config.el b/modules/app/irc/config.el index a232c9fa2..2cb073adc 100644 --- a/modules/app/irc/config.el +++ b/modules/app/irc/config.el @@ -141,6 +141,10 @@ playback.") ;; Fail gracefully if not in a circe buffer (global-set-key [remap tracking-next-buffer] #'+irc/tracking-next-buffer) + (after! marginalia + (when (featurep! :completion selectrum) + (add-to-list 'marginalia-command-categories '(+irc/selectrum-jump-to-channel . buffer)))) + (map! :localleader (:map circe-mode-map "a" #'tracking-next-buffer diff --git a/modules/completion/selectrum/TODO.org b/modules/completion/selectrum/TODO.org index 5d1a372aa..fc0e2721a 100644 --- a/modules/completion/selectrum/TODO.org +++ b/modules/completion/selectrum/TODO.org @@ -41,5 +41,4 @@ are nontrivial loading order shenanigans happening that make that not straightfo *** TODO lookup module *** TODO taskrunner module (doesn't seem to be an interface yet) *** TODO pass module (creating embark-pass can't be that hard) -*** TODO ~+irc/ivy-jump-to-channel~ analogue *** TODO =SPC s B= (~swiper-all~ analogue)