Add hooks so buffers close correctly
This commit is contained in:
parent
ea9f2c07cc
commit
b98abca259
1 changed files with 15 additions and 0 deletions
|
@ -259,6 +259,11 @@ conform to a post plist"
|
||||||
"Mode to list the Mattermost teams and channels to allow the
|
"Mode to list the Mattermost teams and channels to allow the
|
||||||
user to check their status and select between them")
|
user to check their status and select between them")
|
||||||
|
|
||||||
|
(defun mattermost--kill-root-function ()
|
||||||
|
"Function to call when the Mattermost root buffer is killed"
|
||||||
|
(when (eq major-mode 'mattermost-root-mode)
|
||||||
|
(mattermost-disconnect)))
|
||||||
|
|
||||||
(defvar mattermost-username-button-map
|
(defvar mattermost-username-button-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(set-keymap-parent map button-map)
|
(set-keymap-parent map button-map)
|
||||||
|
@ -348,6 +353,12 @@ user to check their status and select between them")
|
||||||
"Mode use on a Mattermost channel buffer, that shows the
|
"Mode use on a Mattermost channel buffer, that shows the
|
||||||
messages of the channel and allows the user to post theirs")
|
messages of the channel and allows the user to post theirs")
|
||||||
|
|
||||||
|
(defun mattermost--kill-buffer-function ()
|
||||||
|
"Function to call when a Mattermost buffer is killed"
|
||||||
|
(when (eq major-mode 'mattermost-channel-mode)
|
||||||
|
(setq mattermost-buffers
|
||||||
|
(plist-put mattermost-buffers (mattermost-string->keyword mattermost-channel-id) nil))))
|
||||||
|
|
||||||
;; ToDo: should we receive just a channel id and fetch the channel
|
;; ToDo: should we receive just a channel id and fetch the channel
|
||||||
;; data?
|
;; data?
|
||||||
(defun mattermost-show-channel (channel)
|
(defun mattermost-show-channel (channel)
|
||||||
|
@ -390,10 +401,14 @@ user to check their status and select between them")
|
||||||
(mattermost-disconnect)
|
(mattermost-disconnect)
|
||||||
(let ((password (mattermost-read-password)))
|
(let ((password (mattermost-read-password)))
|
||||||
(mattermost-login mattermost-login-id password))
|
(mattermost-login mattermost-login-id password))
|
||||||
|
(add-hook 'kill-buffer-hook #'mattermost--kill-root-function)
|
||||||
|
(add-hook 'kill-buffer-hook #'mattermost--kill-buffer-function)
|
||||||
(mattermost-show-root))
|
(mattermost-show-root))
|
||||||
|
|
||||||
(defun mattermost--kill-all-buffers ()
|
(defun mattermost--kill-all-buffers ()
|
||||||
"Kills all Mattermost related buffers"
|
"Kills all Mattermost related buffers"
|
||||||
|
(remove-hook 'kill-buffer-hook #'mattermost--kill-root-function)
|
||||||
|
(remove-hook 'kill-buffer-hook #'mattermost--kill-buffer-function)
|
||||||
(while (car mattermost-buffers)
|
(while (car mattermost-buffers)
|
||||||
(let ((buf (car (cdr mattermost-buffers)))
|
(let ((buf (car (cdr mattermost-buffers)))
|
||||||
(tail (cddr mattermost-buffers)))
|
(tail (cddr mattermost-buffers)))
|
||||||
|
|
Loading…
Reference in a new issue