From 5ce950e168359ff08bb2b5233646fce2fe1716ce Mon Sep 17 00:00:00 2001 From: Milo Davis Date: Wed, 25 Oct 2017 11:27:49 +0200 Subject: [PATCH] Emacs: close types buffer when editing buffer closes --- emacs/michelson-mode.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/emacs/michelson-mode.el b/emacs/michelson-mode.el index ae4aad4d2..94b74989a 100644 --- a/emacs/michelson-mode.el +++ b/emacs/michelson-mode.el @@ -420,7 +420,7 @@ Overrides `michelson-print-errors' and `michelson-highlight-errors'" (get-buffer-window buffer) (display-buffer-below-selected buffer nil)))) (window-body-width message-window))) - + (defun michelson-write-output-buffer (data &optional do-not-overwrite) "Write the given `DATA' to the output buffer. @@ -827,6 +827,14 @@ Enables or disables stack and error display." (michelson-type-at-point)))) (current-buffer)))) +(defun michelson-close-output-buffer () + "Close the interactive editing buffer." + (interactive) + (let ((buffer (get-buffer michelson-output-buffer-name))) + (when buffer + (let ((window (get-buffer-window buffer))) + (if window (quit-window t window) (kill-buffer buffer)))))) + (define-derived-mode michelson-mode prog-mode "Michelson" "Major mode for editing Michelson smart contracts." (interactive) @@ -855,6 +863,7 @@ Enables or disables stack and error display." (make-local-variable 'focus-in-hook) 'michelson-update-minibuffer-info) (add-hook 'post-self-insert-hook 'michelson-clean-cache) + (add-hook 'kill-buffer-hook 'michelson-close-output-buffer t t) (setq major-mode 'michelson-mode) (setq mode-name "Michelson") (setq indent-tabs-mode nil)