diff options
| -rw-r--r-- | chess-display.el | 12 | ||||
| -rw-r--r-- | chess-engine.el | 5 | ||||
| -rw-r--r-- | chess-images.el | 1 |
3 files changed, 15 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 diff --git a/chess-engine.el b/chess-engine.el index 219bf34..909b7b7 100644 --- a/chess-engine.el +++ b/chess-engine.el @@ -134,8 +134,13 @@ (set-process-buffer proc (current-buffer)) (set-process-filter proc 'chess-engine-filter)) (setq chess-engine-current-marker (point-marker))) + (add-hook 'kill-buffer-hook 'chess-engine-on-kill nil t) (current-buffer)))) +(defun chess-engine-on-kill () + "Function called when the buffer is killed." + (chess-engine-detach-game nil)) + (defun chess-engine-destroy (engine) (let ((buf (or engine (current-buffer)))) (if (buffer-live-p buf) diff --git a/chess-images.el b/chess-images.el index ec07b79..6a202d5 100644 --- a/chess-images.el +++ b/chess-images.el @@ -196,6 +196,7 @@ called." (max-char-width (ceiling (/ size (frame-char-width)))) (display (and (stringp chess-images-separate-frame) chess-images-separate-frame))) + ;; create the frame whenever necessary (chess-display-popup-in-frame display (+ max-char-height 2) max-char-width)) (chess-display-popup-in-window))) |
