bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12708: 24.1; M-x display-time-world "q" close window


From: Juri Linkov
Subject: bug#12708: 24.1; M-x display-time-world "q" close window
Date: Wed, 24 Oct 2012 10:44:44 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu)

> We could do
>
> (defun quit-window-kill-buffer (&optional window)
>   "Quit WINDOW and kill its buffer.
> WINDOW must be a live window and defaults to the selected one."
>   (interactive)
>   (quit-restore-window window 'kill))
>
> (defvar display-time-world-mode-map
>   (let ((map (make-sparse-keymap)))
>     (define-key map "q" 'quit-window-kill-buffer)
>     map)
>   "Keymap of Display Time World mode.")

BTW, when I needed to do the same for the *Occur* buffer
(to kill it after going to the occurrence) I created a new command
`occur-mode-goto-occurrence-kill-buffer' based on
`occur-mode-goto-occurrence-other-window':

(defun occur-mode-goto-occurrence-kill-buffer ()
  "Go to the occurrence the current line describes, and kill the Occur buffer."
  (interactive)
  (let ((buf (current-buffer))
        (pos (occur-mode-find-occurrence)))
    (switch-to-buffer-other-window (marker-buffer pos))
    (goto-char pos)
    (kill-buffer buf)
    (run-hooks 'occur-mode-find-occurrence-hook)))

I still have no idea how to generalize this common behavior.

> But `display-time-world' should probably also use `display-buffer'
> instead of `pop-to-buffer' and put the buffer in `view-mode'.  After
> all, who wants to edit or navigate the *wclock* buffer?

In addition to this, it could also use the action
`display-buffer-below-selected' (like in dired),
and instead of `fit-window-to-buffer' it could use
'((window-height . fit-window-to-buffer)).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]