Merge pull request #1130 from seanfarley/smf/irc

irc: automatically add circe buffers to irc workspace
This commit is contained in:
Henrik Lissner 2019-01-21 22:22:41 -05:00 committed by GitHub
commit 26caa28e8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 14 deletions

View file

@ -44,8 +44,8 @@ custom keybinding.
When in a circe buffer these keybindings will be available. When in a circe buffer these keybindings will be available.
| command | key | description | | command | key | description |
|------------------------+-----------+----------------------------------------------| |-----------------------------+-----------+----------------------------------------------|
| ~tracking-next-buffer~ | =SPC m a= | Switch to the next active buffer | | ~+irc/tracking-next-buffer~ | =SPC m a= | Switch to the next active buffer |
| ~circe-command-JOIN~ | =SPC m j= | Join a channel | | ~circe-command-JOIN~ | =SPC m j= | Join a channel |
| ~+irc/send-message~ | =SPC m m= | Send a private message | | ~+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-NAMES~ | =SPC m n= | List the names of the current channel |

View file

@ -117,13 +117,40 @@ playback.")
'((text-properties . (face circe-fool-face lui-do-not-track t))))) '((text-properties . (face circe-fool-face lui-do-not-track t)))))
(add-hook 'circe-message-option-functions #'+irc|circe-message-option-bot) (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 (after! solaire-mode
;; distinguish chat/channel buffers from server buffers. ;; distinguish chat/channel buffers from server buffers.
(add-hook 'circe-chat-mode-hook #'solaire-mode)) (add-hook 'circe-chat-mode-hook #'solaire-mode))
(map! :localleader (map! :localleader
(:map circe-mode-map (:map circe-mode-map
"a" #'tracking-next-buffer "a" #'+irc/tracking-next-buffer
"j" #'circe-command-JOIN "j" #'circe-command-JOIN
"m" #'+irc/send-message "m" #'+irc/send-message
"p" #'circe-command-PART "p" #'circe-command-PART
@ -186,6 +213,9 @@ after prompt marker."
(add-hook! 'lui-mode-hook (add-hook! 'lui-mode-hook
(add-hook 'evil-insert-state-entry-hook #'+irc|evil-insert nil t)) (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)) (mapc (lambda (cmd) (push cmd +irc-scroll-to-bottom-on-commands))
'(evil-paste-after evil-paste-before evil-open-above evil-open-below))) '(evil-paste-after evil-paste-before evil-open-above evil-open-below)))

View file

@ -172,6 +172,7 @@
(:when (featurep! :app irc) (:when (featurep! :app irc)
(:prefix ("I" . "irc") (:prefix ("I" . "irc")
:desc "Open irc app" "i" #'=irc :desc "Open irc app" "i" #'=irc
:desc "Next unread buffer" "a" #'+irc/tracking-next-buffer
:desc "Quit irc" "q" #'+irc/quit :desc "Quit irc" "q" #'+irc/quit
:desc "Reconnect all" "r" #'circe-reconnect-all :desc "Reconnect all" "r" #'circe-reconnect-all
:desc "Send message" "s" #'+irc/send-message :desc "Send message" "s" #'+irc/send-message