summaryrefslogtreecommitdiff
path: root/chess-display.el
diff options
context:
space:
mode:
Diffstat (limited to 'chess-display.el')
-rw-r--r--chess-display.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/chess-display.el b/chess-display.el
index 68aeea4..f45429e 100644
--- a/chess-display.el
+++ b/chess-display.el
@@ -87,13 +87,19 @@
(funcall handler 'initialize)
(setq chess-display-event-handler handler
chess-display-perspective perspective)
+ (add-hook 'kill-buffer-hook 'chess-display-on-kill nil t)
(current-buffer))))
-(defsubst chess-display-destroy (display)
+(defun chess-display-on-kill ()
+ "Function called when the buffer is killed."
+ (chess-display-detach-game nil))
+
+(defun chess-display-destroy (display)
"Destroy a chess display object, killing all of its buffers."
(let ((buf (or display (current-buffer))))
- (if (buffer-live-p buf)
- (kill-buffer buf))))
+ (when (buffer-live-p buf)
+ (chess-display-detach-game display)
+ (kill-buffer buf))))
(defsubst chess-display-perspective (display)
(chess-with-current-buffer display