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

[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: Drew Adams
Subject: RE: check to see if a buffer with a certain name exists?
Date: Thu, 13 Nov 2008 08:45:50 -0800

> 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::.





reply via email to

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