What would be the proper way to pop up a window (preferably in the current frame),with a message? I also want to locally (in that buffer only) the q
key to a function that will kill the buffer and the window (similar to what is done in IELM's error pop-ups, but it won't be an error pop-up).
I have tried this:
(defun kill-buffer-and-window ()
(kill-this-buffer)
(if (not (one-window-p))
(delete-window)))
(defun cool-message ()
(interactive)
(pop-to-buffer "*cool-message-buffer*")
(use-local-map (make-sparse-keymap)) ; don't change bindings for other buffers
(local-set-key "q" 'kill-buffer-and-window)
(insert "Yo!!!"))
(local-set-key "x" 'cool-message)
I know that local-set-key
will change the binding for all buffers using the same major-mode -- this is just a quick hack to show what I want.
The problem is that hitting q
in the buffer that pops up will not kill it.
What did I miss? Do I need to create a minor mode?