diff --git a/modules/app/irc/README.org b/modules/app/irc/README.org index 7eb017008..d4cb00367 100644 --- a/modules/app/irc/README.org +++ b/modules/app/irc/README.org @@ -43,15 +43,15 @@ custom keybinding. When in a circe buffer these keybindings will be available. -| command | key | description | -|------------------------+-----------+----------------------------------------------| -| ~tracking-next-buffer~ | =SPC m a= | Switch to the next active buffer | -| ~circe-command-JOIN~ | =SPC m j= | Join a channel | -| ~+irc/send-message~ | =SPC m m= | Send a private message | -| ~circe-command-NAMES~ | =SPC m n= | List the names of the current channel | -| ~circe-command-PART~ | =SPC m p= | Part the current channel | -| ~+irc/quit~ | =SPC m Q= | Kill the current circe session and workgroup | -| ~circe-reconnect~ | =SPC m R= | Reconnect the current server | +| command | key | description | +|-----------------------------+-----------+----------------------------------------------| +| ~+irc/tracking-next-buffer~ | =SPC m a= | Switch to the next active buffer | +| ~circe-command-JOIN~ | =SPC m j= | Join a channel | +| ~+irc/send-message~ | =SPC m m= | Send a private message | +| ~circe-command-NAMES~ | =SPC m n= | List the names of the current channel | +| ~circe-command-PART~ | =SPC m p= | Part the current channel | +| ~+irc/quit~ | =SPC m Q= | Kill the current circe session and workgroup | +| ~circe-reconnect~ | =SPC m R= | Reconnect the current server | * Configuration Use ~set-irc-server!~ to configure IRC servers. Its second argument (a plist) diff --git a/modules/app/irc/config.el b/modules/app/irc/config.el index f72bb8abb..108faa9cc 100644 --- a/modules/app/irc/config.el +++ b/modules/app/irc/config.el @@ -117,13 +117,40 @@ playback.") '((text-properties . (face circe-fool-face lui-do-not-track t))))) (add-hook 'circe-message-option-functions #'+irc|circe-message-option-bot) + (defun +circe-buffer-p (buf) + "Return non-nil if BUF is a `circe-mode' buffer." + (with-current-buffer buf + (and (derived-mode-p 'circe-mode) + (eq (safe-persp-name (get-current-persp)) + +irc--workspace-name)))) + (add-hook 'doom-real-buffer-functions #'+circe-buffer-p) + + (defun +irc|add-circe-buffer-to-persp () + (let ((persp (get-current-persp)) + (buf (current-buffer))) + ;; only add a new circe buffer to the irc workspace when we're in another + ;; workspace + (unless (eq (safe-persp-name persp) +irc--workspace-name) + ;; add new circe buffers to the persp containing circe buffers + (persp-add-buffer buf + (persp-get-by-name +irc--workspace-name)) + ;; remove new buffer from accidental workspace + (persp-remove-buffer buf persp)))) + (add-hook 'circe-mode-hook #'+irc|add-circe-buffer-to-persp) + + (defun +irc/tracking-next-buffer () + "Dissables switching to an unread buffer unless in the irc workspace." + (interactive) + (when (derived-mode-p 'circe-mode) + (tracking-next-buffer))) + (after! solaire-mode ;; distinguish chat/channel buffers from server buffers. (add-hook 'circe-chat-mode-hook #'solaire-mode)) (map! :localleader (:map circe-mode-map - "a" #'tracking-next-buffer + "a" #'+irc/tracking-next-buffer "j" #'circe-command-JOIN "m" #'+irc/send-message "p" #'circe-command-PART @@ -186,6 +213,9 @@ after prompt marker." (add-hook! 'lui-mode-hook (add-hook 'evil-insert-state-entry-hook #'+irc|evil-insert nil t)) + ;; enable a horizontal line marking the last read message + (add-hook 'lui-mode-hook #'enable-lui-track-bar) + (mapc (lambda (cmd) (push cmd +irc-scroll-to-bottom-on-commands)) '(evil-paste-after evil-paste-before evil-open-above evil-open-below))) diff --git a/modules/config/default/+emacs-bindings.el b/modules/config/default/+emacs-bindings.el index ae95f1abb..0edd2786e 100644 --- a/modules/config/default/+emacs-bindings.el +++ b/modules/config/default/+emacs-bindings.el @@ -171,10 +171,11 @@ ;; IRC (:when (featurep! :app irc) (:prefix ("I" . "irc") - :desc "Open irc app" "i" #'=irc - :desc "Quit irc" "q" #'+irc/quit - :desc "Reconnect all" "r" #'circe-reconnect-all - :desc "Send message" "s" #'+irc/send-message + :desc "Open irc app" "i" #'=irc + :desc "Next unread buffer" "a" #'+irc/tracking-next-buffer + :desc "Quit irc" "q" #'+irc/quit + :desc "Reconnect all" "r" #'circe-reconnect-all + :desc "Send message" "s" #'+irc/send-message (:when (featurep! :completion ivy) :desc "Jump to channel" "j" #'irc/ivy-jump-to-channel))) ;; Twitter