all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* resize remaining buffer after kill buffer
@ 2003-08-11  8:03 Torsten Müller
  2003-08-11 12:34 ` Joakim Hove
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Torsten Müller @ 2003-08-11  8:03 UTC (permalink / raw)


If I have two (or more) buffers visible and I kill one of these
buffers, the size of the remaining buffers is still as before. The
area of the disappeared buffer will then be filled by something else,
mostly the scratch buffer or something else which is normally _not_
interesting for me.

Is there any simple way to enlarge one of the remaining buffers by the
size of the just killed buffer?

T.M.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: resize remaining buffer after kill buffer
  2003-08-11  8:03 resize remaining buffer after kill buffer Torsten Müller
@ 2003-08-11 12:34 ` Joakim Hove
  2003-08-11 12:43   ` Torsten Müller
  2003-08-11 15:04 ` Stefan Monnier
  2003-08-12 18:36 ` Kai Großjohann
  2 siblings, 1 reply; 7+ messages in thread
From: Joakim Hove @ 2003-08-11 12:34 UTC (permalink / raw)




Homunkulus@gmx.net (Torsten Müller) writes:


> Is there any simple way to enlarge one of the remaining buffers by the
> size of the just killed buffer?

Hello,

I don't know if this is what you want but:

(defun kill-buffer-and-window (BUFFER)
  "Kills a buffer and the accompanying window. If the buffer is not
displayed in the active frame nothing happens to the window 
configuration"
  (interactive "bKill buffer:")
  (let ((window))
    (if (> (count-windows) 1)
	(setq window (get-buffer-window BUFFER)))
    (kill-buffer BUFFER)
    (if window
	(delete-window window))))
    
does something alike.

*Warning* After writing this function I discovered that there already
exists a built in function with the same name, however It seems the
built function does not allow you to select which buffer to kill. In
my implementation nothing happens if you kill a buffer which does not
occupy a window in the current frame.

Joakim

-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / hove@bccs.no  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: resize remaining buffer after kill buffer
  2003-08-11 12:34 ` Joakim Hove
@ 2003-08-11 12:43   ` Torsten Müller
  2003-08-11 13:31     ` Torsten Müller
  0 siblings, 1 reply; 7+ messages in thread
From: Torsten Müller @ 2003-08-11 12:43 UTC (permalink / raw)


Joakim Hove <hove@bccs.no> schrieb:

> *Warning* After writing this function I discovered that there
> already exists a built in function with the same name,

Oh. Indeed.

> however It seems the built function does not allow you to select
> which buffer to kill. In my implementation nothing happens if you
> kill a buffer which does not occupy a window in the current frame.

In my implementation this function seems to do everything right, even
with selection of the buffer. (I want always the buffer with the
cursor.)

Thanks for your code.

T.M.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: resize remaining buffer after kill buffer
  2003-08-11 12:43   ` Torsten Müller
@ 2003-08-11 13:31     ` Torsten Müller
  2003-08-11 13:38       ` Joakim Hove
  0 siblings, 1 reply; 7+ messages in thread
From: Torsten Müller @ 2003-08-11 13:31 UTC (permalink / raw)


Homunkulus@gmx.net (Torsten Müller) schrieb:

> Thanks for your code.

I experimented a bit with your code and with the other function having
the same name. The problem of the other function is that it doesn't
delete a buffer which has full size. But I want to have a function for
all purpuse use (on C-x k). So, my dream is something like this:

(defun kill-this-buffer-and-window ()
  "Kill the current buffer and delete the selected window."
  (interactive)
  (let (buffer current-buffer)
    (kill-buffer buffer)
    (if (> (count-windows) 1)
      (delete-window (selected-window)))
  )
)

T.M.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: resize remaining buffer after kill buffer
  2003-08-11 13:31     ` Torsten Müller
@ 2003-08-11 13:38       ` Joakim Hove
  0 siblings, 0 replies; 7+ messages in thread
From: Joakim Hove @ 2003-08-11 13:38 UTC (permalink / raw)



Homunkulus@gmx.net (Torsten Müller) writes:

> So, my dream is something like this:
> (defun kill-this-buffer-and-window ()
>   "Kill the current buffer and delete the selected window."
>   (interactive)
>   (let (buffer current-buffer)
>     (kill-buffer buffer)
>     (if (> (count-windows) 1)
>       (delete-window (selected-window)))
>   )
> )

Well, this looks nice to me - so then "your dream is fulfilled" - or?
The implementation above does not let you choose the buffer to kill,
but I agree with you that that is a quite stupid choise to get anyway.

One final tip: (kill-buffer) returns true if the buffer is actually
killed, nil otherwise. So you *could* wrap the (delete-window ) call a
bit:

;;...
(if (kill-buffer (current-buffer))
    (if (> (count-windows) 1)
        (delete-window (selected-window))))


Joakim




-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / hove@bccs.no  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: resize remaining buffer after kill buffer
  2003-08-11  8:03 resize remaining buffer after kill buffer Torsten Müller
  2003-08-11 12:34 ` Joakim Hove
@ 2003-08-11 15:04 ` Stefan Monnier
  2003-08-12 18:36 ` Kai Großjohann
  2 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2003-08-11 15:04 UTC (permalink / raw)


> If I have two (or more) buffers visible and I kill one of these
> buffers, the size of the remaining buffers is still as before. The

Be careful to distinguish buffers and windows.
You're talking about the size of the window(s), not about the size of
the buffers.


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: resize remaining buffer after kill buffer
  2003-08-11  8:03 resize remaining buffer after kill buffer Torsten Müller
  2003-08-11 12:34 ` Joakim Hove
  2003-08-11 15:04 ` Stefan Monnier
@ 2003-08-12 18:36 ` Kai Großjohann
  2 siblings, 0 replies; 7+ messages in thread
From: Kai Großjohann @ 2003-08-12 18:36 UTC (permalink / raw)


Homunkulus@gmx.net (Torsten Müller) writes:

> Is there any simple way to enlarge one of the remaining buffers by the
> size of the just killed buffer?

I think you want to kill the buffer and the window -- C-x 4 0.
-- 
Two cafe au lait please, but without milk.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-08-12 18:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-11  8:03 resize remaining buffer after kill buffer Torsten Müller
2003-08-11 12:34 ` Joakim Hove
2003-08-11 12:43   ` Torsten Müller
2003-08-11 13:31     ` Torsten Müller
2003-08-11 13:38       ` Joakim Hove
2003-08-11 15:04 ` Stefan Monnier
2003-08-12 18:36 ` Kai Großjohann

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.