[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: check to see if a buffer with a certain name exists?
From: |
Matt Price |
Subject: |
RE: check to see if a buffer with a certain name exists? |
Date: |
Fri, 14 Nov 2008 10:35:01 -0500 |
On Thu, 2008-11-13 at 08:45 -0800, Drew Adams wrote:
> > i want to be able to check if there's a buffer
> > open named *Mutt* . what's the best way to do this? in python, for
> > instance, i would just say:
> > if "*Mutt*" in buffer-list : return true else : return false
> > in lisp i'm not seeing a quick way to test for something like this.
>
> C-h f get-buffer
>
> (get-buffer "*Mutt*")
>
> The Elisp manual is your friend. In the manual, `i buffer RET' takes you to
> the
> Buffers chapter. Buffer Names in the menu there shows you this:
>
> Function: get-buffer buffer-or-name
> This function returns the buffer specified by BUFFER-OR-NAME. If
> BUFFER-OR-NAME is a string and there is no buffer with that name,
> the value is `nil'. If BUFFER-OR-NAME is a buffer, it is returned
> as given; that is not very useful, so the argument is usually a
> name. For example:
>
> (setq b (get-buffer "lewis"))
> => #<buffer lewis>
> (get-buffer b)
> => #<buffer lewis>
> (get-buffer "Frazzle-nots")
> => nil
>
> See also the function `get-buffer-create' in *note Creating
> Buffers::.
>
thanks Drew! i am still getting used to info, thanks. i had looked up
buffers inthe online manual but missed get-buffer, clearly it's exactly
what i'm looking for, thanks again!
matt
--
Matt Price
matt.price@utoronto.ca