emacs-devel
[Top][All Lists]
Advanced

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

Re: occur-hook changing the current buffer


From: Juanma Barranquero
Subject: Re: occur-hook changing the current buffer
Date: Thu, 23 Jun 2005 16:45:37 +0200

On 6/23/05, Emilio Lopes <address@hidden> wrote:

> Don't know if it helps you, but I have the following in my "~/.emacs" and it
> seems to work:
> 
> (defun occur-shrink-window ()
>   "*Shrink the \"*Occur*\" window as much as possible to display its 
> contents."
>   (let ((win (get-buffer-window "*Occur*")))
>     (when (windowp win)
>       (shrink-window-if-larger-than-buffer win))))
> (add-hook 'occur-hook 'occur-shrink-window)

I have something similar:

  (defun lk-fit-window (&optional buffer min-height)
    "Resize window showing BUFFER to fit its contents."
    (interactive)
    (fit-window-to-buffer (get-buffer-window (or buffer (current-buffer)))
                          (if (integerp max-mini-window-height)
                              max-mini-window-height
                            (floor (* (frame-height) max-mini-window-height)))
                          (or min-height 2)))

  (add-hook 'occur-hook #'lk-fit-window)

I use lk-fit-window at other places on my .emacs, that's why it is
more complex than needed just for `occur-hook'.

The issue is that `fit-window-to-buffer', when called from
`occur-hook', changes the current buffer. Puzzling. Not a problem now,
because I've wrapped the call in lk-fit-window with
`save-current-buffer', but still, it seems like a bug to me.

Just out of curiosity: do you usually work in a just-one-window
configuration? I don't like having to make C-x 1 continuously, so I've
set up help modes (and everything else that could be customized to do
so) to be "electric": use, press "q", and you're back to one window.
About the only time I use two windows is on inferior modes (when
running IELM, a Common Lisp, Haskell, MySQL, etc.), and even then I've
setup a way to show the inferior modes in a window (about a third of
the frame) on the lower, and I've set up F12 to switch between
bringing this window up and burying.

-- 
                    /L/e/k/t/u




reply via email to

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