diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-15 01:31:08 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2014-11-15 01:31:08 +0000 |
commit | 598450c62e7ecc971b4cc5227343da10360ba978 (patch) | |
tree | 71c13e5cab7c1e65c4630b32e85bb0e1c958f904 | |
parent | 615c3404c0aea4db77c6e417a9a9febdf784f245 (diff) |
Close question window with q
-rw-r--r-- | sx-question-list.el | 10 | ||||
-rw-r--r-- | sx-question-mode.el | 5 |
2 files changed, 14 insertions, 1 deletions
diff --git a/sx-question-list.el b/sx-question-list.el index a1dec7a..c6eb58e 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -285,7 +285,7 @@ focus the relevant window." (null (equal sx-question-mode--window (selected-window)))) (setq sx-question-mode--window (condition-case er - (split-window-below sx-question-list-height) + (split-window (selected-window) sx-question-list-height 'below) (error ;; If the window is too small to split, use current one. (if (string-match @@ -293,7 +293,15 @@ focus the relevant window." (car (cdr-safe er))) nil (error (cdr er))))))) + ;; Display the question. (sx-question-mode--display data sx-question-mode--window) + ;; Configure the window to be closed on `q'. + (set-window-prev-buffers sx-question-mode--window nil) + (set-window-parameter + sx-question-mode--window + 'quit-restore + ;; See https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Parameters.html#Window-Parameters + `(window window ,(selected-window) ,sx-question-mode--buffer)) (when focus (if sx-question-mode--window (select-window sx-question-mode--window) diff --git a/sx-question-mode.el b/sx-question-mode.el index 5afb2e8..2ef22cb 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -523,6 +523,11 @@ If DIRECTION is negative, move backwards instead." Letters do not insert themselves; instead, they are commands. \\<sx-question-mode> \\{sx-question-mode}" + ;; Determine how to close this window. + (unless (window-parameter nil 'quit-restore) + (set-window-parameter + nil 'quit-restore + `(other window nil ,(current-buffer)))) ;; We call font-lock-region manually. See `sx-question-mode--fill-and-fontify' (font-lock-mode -1) (remove-hook 'after-change-functions 'markdown-check-change-for-wiki-link t) |