* If exists, Kill buffer
@ 2005-10-07 16:25 Tim Johnson
2005-10-07 16:32 ` J. David Boyd
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Tim Johnson @ 2005-10-07 16:25 UTC (permalink / raw)
I need a function that will kill a (named) buffer if it exists.
1)Is there one?
a)If not, I will need a function that checks for the existance
of a buffer by name.
b)Is there one?
Pointers to docs, resources welcomed.
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: If exists, Kill buffer
2005-10-07 16:25 If exists, Kill buffer Tim Johnson
@ 2005-10-07 16:32 ` J. David Boyd
2005-10-07 16:34 ` Lennart Borgman
2005-10-07 16:37 ` Slawomir Nowaczyk
2 siblings, 0 replies; 8+ messages in thread
From: J. David Boyd @ 2005-10-07 16:32 UTC (permalink / raw)
Tim Johnson <tim@johnsons-web.com> writes:
> I need a function that will kill a (named) buffer if it exists.
> 1)Is there one?
> a)If not, I will need a function that checks for the existance
> of a buffer by name.
> b)Is there one?
> Pointers to docs, resources welcomed.
> tim
>
> --
> Tim Johnson <tim@johnsons-web.com>
> http://www.alaska-internet-solutions.com
I don't recall where I came by this, on this group probably...
(defun kill-buffers-matching (regexp)
(interactive "sKill buffers matching: ")
(dolist (i
(buffer-list))
(when (string-match regexp (buffer-name i))
(kill-buffer i))))
Dave in Largo, FL
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: If exists, Kill buffer
2005-10-07 16:25 If exists, Kill buffer Tim Johnson
2005-10-07 16:32 ` J. David Boyd
@ 2005-10-07 16:34 ` Lennart Borgman
2005-10-07 16:37 ` Slawomir Nowaczyk
2 siblings, 0 replies; 8+ messages in thread
From: Lennart Borgman @ 2005-10-07 16:34 UTC (permalink / raw)
Cc: help-gnu-emacs
Tim Johnson wrote:
>I need a function that will kill a (named) buffer if it exists.
>1)Is there one?
> a)If not, I will need a function that checks for the existance
> of a buffer by name.
> b)Is there one?
>Pointers to docs, resources welcomed.
>tim
>
>
>
(get-buffer NAME)
Use C-h get-buffer RET to get basic documentation.
In the Elisp manual you can look under "Buffers" - "Buffer Names".
If you are using CVS Emacs (next generation of Emacs, not yet released)
you can find this manual by first selecting from the menus "Help - Read
Emacs Manual" and then then choose Emacs Lisp. If you are using current
Emacs (version 21.3) it can happen that it is not installed by default.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: If exists, Kill buffer
2005-10-07 16:25 If exists, Kill buffer Tim Johnson
2005-10-07 16:32 ` J. David Boyd
2005-10-07 16:34 ` Lennart Borgman
@ 2005-10-07 16:37 ` Slawomir Nowaczyk
2005-10-07 16:53 ` Tim Johnson
2 siblings, 1 reply; 8+ messages in thread
From: Slawomir Nowaczyk @ 2005-10-07 16:37 UTC (permalink / raw)
On Fri, 07 Oct 2005 08:25:52 -0800
Tim Johnson <tim@johnsons-web.com> wrote:
#> I need a function that will kill a (named) buffer if it exists.
#> 1)Is there one?
How about (kill-buffer (get-buffer "blabla")) ?
#> a)If not, I will need a function that checks for the existance
#> of a buffer by name.
C-h f get-buffer
#> b)Is there one?
Yes
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
When the GM grins, it is too late to run.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: If exists, Kill buffer
2005-10-07 16:37 ` Slawomir Nowaczyk
@ 2005-10-07 16:53 ` Tim Johnson
2005-10-07 20:15 ` Slawomir Nowaczyk
0 siblings, 1 reply; 8+ messages in thread
From: Tim Johnson @ 2005-10-07 16:53 UTC (permalink / raw)
Thank you folks!
You have me on the right track (I think).
I believe something like:
(if (get-buffer "*Help*")(kill-buffer "*Help*"))
will do the trick.
Cheers
tim
* Slawomir Nowaczyk <slawomir.nowaczyk.847@student.lu.se> [051007 08:43]:
> On Fri, 07 Oct 2005 08:25:52 -0800
> Tim Johnson <tim@johnsons-web.com> wrote:
>
> #> I need a function that will kill a (named) buffer if it exists.
> #> 1)Is there one?
>
> How about (kill-buffer (get-buffer "blabla")) ?
>
> #> a)If not, I will need a function that checks for the existance
> #> of a buffer by name.
>
> C-h f get-buffer
>
> #> b)Is there one?
>
> Yes
>
> --
> Best wishes,
> Slawomir Nowaczyk
> ( slawomir.nowaczyk.847@student.lu.se )
>
> When the GM grins, it is too late to run.
>
>
>
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: If exists, Kill buffer
2005-10-07 16:53 ` Tim Johnson
@ 2005-10-07 20:15 ` Slawomir Nowaczyk
2005-10-07 20:23 ` Edward O'Connor
0 siblings, 1 reply; 8+ messages in thread
From: Slawomir Nowaczyk @ 2005-10-07 20:15 UTC (permalink / raw)
On Fri, 07 Oct 2005 08:53:19 -0800
Tim Johnson <tim@johnsons-web.com> wrote:
#> Thank you folks!
#>
#> You have me on the right track (I think).
#>
#> I believe something like:
#> (if (get-buffer "*Help*")(kill-buffer "*Help*"))
#> will do the trick.
Well, actually just:
(kill-buffer (get-buffer "blabla"))
works for me (but I use EmacsCVS, it may behave differently in 21.4 or
whatever you are using).
Anyway, for me get-buffer returns nil if no matching buffer is found,
and (kill-buffer nil) seems to be a no-op.
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
Living your life is a task so difficult, it has never
been attempted before.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: If exists, Kill buffer
2005-10-07 20:15 ` Slawomir Nowaczyk
@ 2005-10-07 20:23 ` Edward O'Connor
2005-10-07 22:16 ` Slawomir Nowaczyk
0 siblings, 1 reply; 8+ messages in thread
From: Edward O'Connor @ 2005-10-07 20:23 UTC (permalink / raw)
Slawomir Nowaczyk wrote:
> and (kill-buffer nil) seems to be a no-op.
Err.
(kill-buffer nil) kills the current buffer, which is no no-op.
Ted
--
Edward O'Connor
hober0@gmail.com
Ense petit placidam sub libertate quietem.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: If exists, Kill buffer
2005-10-07 20:23 ` Edward O'Connor
@ 2005-10-07 22:16 ` Slawomir Nowaczyk
0 siblings, 0 replies; 8+ messages in thread
From: Slawomir Nowaczyk @ 2005-10-07 22:16 UTC (permalink / raw)
On Fri, 07 Oct 2005 13:23:55 -0700
Edward O'Connor <hober0@gmail.com> wrote:
#> Slawomir Nowaczyk wrote:
#>
#> > and (kill-buffer nil) seems to be a no-op.
#>
#> Err.
#>
#> (kill-buffer nil) kills the current buffer, which is no no-op.
Hmm... funny...
<goes back to his test case> ... <comes back with a brown paper bag
over his head> Yes, you are right... my testing was flawed: I have
forgotten my *scratch* buffer is protected against killing.
Sorry about that.
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
You can't wake a person who is pretending to be asleep.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-10-07 22:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-07 16:25 If exists, Kill buffer Tim Johnson
2005-10-07 16:32 ` J. David Boyd
2005-10-07 16:34 ` Lennart Borgman
2005-10-07 16:37 ` Slawomir Nowaczyk
2005-10-07 16:53 ` Tim Johnson
2005-10-07 20:15 ` Slawomir Nowaczyk
2005-10-07 20:23 ` Edward O'Connor
2005-10-07 22:16 ` Slawomir Nowaczyk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).