app/irc: refactor & fix #1616

This commit is contained in:
Henrik Lissner 2019-07-29 12:18:08 +02:00
parent 0f9ce4de67
commit 2b1c60fbd4
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 28 additions and 20 deletions

View file

@ -97,3 +97,27 @@ argument) is non-nil only show channels in current server."
(interactive)
(when (derived-mode-p 'circe-mode)
(tracking-next-buffer)))
;;
;;; Hooks/fns
;;;###autoload
(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))))
;;;###autoload
(defun +irc--add-circe-buffer-to-persp-h ()
(when (bound-and-true-p persp-mode)
(let ((persp (get-current-persp))
(buf (current-buffer)))
;; Add a new circe buffer to 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)))))