all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* check if these is a buffer to a file
@ 2009-02-16  3:04 Kiwon Um
  2009-02-16  3:50 ` Andy Stewart
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kiwon Um @ 2009-02-16  3:04 UTC (permalink / raw)
  To: help-gnu-emacs

Hello. I'm now writing some lisp codes.

I want to write some codes that kill a buffer if it is already opened
(visited).
Is there any predefined function to check the existence of a buffer?

Thanks. :)


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

* Re: check if these is a buffer to a file
  2009-02-16  3:04 check if these is a buffer to a file Kiwon Um
@ 2009-02-16  3:50 ` Andy Stewart
       [not found] ` <mailman.832.1234756520.31690.help-gnu-emacs@gnu.org>
  2009-02-16  8:03 ` Tassilo Horn
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Stewart @ 2009-02-16  3:50 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

Kiwon Um <um.kiwon@gmail.com> writes:

> Hello. I'm now writing some lisp codes.
>
> I want to write some codes that kill a buffer if it is already opened
> (visited).
> Is there any predefined function to check the existence of a buffer?
Try to use function `get-buffer'.
Below is document of function `get-buffer':

,----
| (get-buffer BUFFER-OR-NAME)
| 
| Return the buffer named BUFFER-OR-NAME.
| BUFFER-OR-NAME must be either a string or a buffer.  If BUFFER-OR-NAME
| is a string and there is no buffer with that name, return nil.  If
| BUFFER-OR-NAME is a buffer, return it as given.
`----

  -- Andy







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

* Re: check if these is a buffer to a file
       [not found] ` <mailman.832.1234756520.31690.help-gnu-emacs@gnu.org>
@ 2009-02-16  4:07   ` Kiwon Um
  2009-02-16  5:26   ` Jason Rumney
  1 sibling, 0 replies; 5+ messages in thread
From: Kiwon Um @ 2009-02-16  4:07 UTC (permalink / raw)
  To: help-gnu-emacs

On 2월16일, 오후12시50분, Andy Stewart <lazycat.mana...@gmail.com> wrote:
> Hi,
>
> Kiwon Um <um.ki...@gmail.com> writes:
> > Hello. I'm now writing some lisp codes.
>
> > I want to write some codes that kill a buffer if it is already opened
> > (visited).
> > Is there any predefined function to check the existence of a buffer?
>
> Try to use function `get-buffer'.
> Below is document of function `get-buffer':
>
> ,----
> | (get-buffer BUFFER-OR-NAME)
> |
> | Return the buffer named BUFFER-OR-NAME.
> | BUFFER-OR-NAME must be either a string or a buffer.  If BUFFER-OR-NAME
> | is a string and there is no buffer with that name, return nil.  If
> | BUFFER-OR-NAME is a buffer, return it as given.
> `----
>
>   -- Andy

Thanks, it works well. :)
(if (get-buffer "SOMETHING") (kill-buffer "SOMETHING"))


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

* Re: check if these is a buffer to a file
       [not found] ` <mailman.832.1234756520.31690.help-gnu-emacs@gnu.org>
  2009-02-16  4:07   ` Kiwon Um
@ 2009-02-16  5:26   ` Jason Rumney
  1 sibling, 0 replies; 5+ messages in thread
From: Jason Rumney @ 2009-02-16  5:26 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 16, 11:50 am, Andy Stewart <lazycat.mana...@gmail.com> wrote:

> Try to use function `get-buffer'.

get-file-buffer is probably more appropriate to what the Subject line
says.


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

* Re: check if these is a buffer to a file
  2009-02-16  3:04 check if these is a buffer to a file Kiwon Um
  2009-02-16  3:50 ` Andy Stewart
       [not found] ` <mailman.832.1234756520.31690.help-gnu-emacs@gnu.org>
@ 2009-02-16  8:03 ` Tassilo Horn
  2 siblings, 0 replies; 5+ messages in thread
From: Tassilo Horn @ 2009-02-16  8:03 UTC (permalink / raw)
  To: help-gnu-emacs

Kiwon Um <um.kiwon@gmail.com> writes:

Hi!

> Hello. I'm now writing some lisp codes.

Have fun.

> I want to write some codes that kill a buffer if it is already opened
> (visited).  Is there any predefined function to check the existence of
> a buffer?

If you find a file twice, the second time no new buffer will be opened
but it'll be switched to the existing one.  So there's no need to write
some elisp code here.

,----[ C-h f find-file RET ]
| find-file is an interactive compiled Lisp function in `files.el'.
| 
| It is bound to <open>, C-x C-f, <menu-bar> <file> <new-file>.
| 
| (find-file filename &optional wildcards)
| 
| Edit file filename.
| Switch to a buffer visiting file filename,
| creating one if none already exists.
| Interactively, the default if you just type RET is the current directory,
| but the visited file name is available through the minibuffer history:
| type M-n to pull it into the minibuffer.
| 
| You can visit files on remote machines by specifying something
| like /ssh:SOME_REMOTE_MACHINE:FILE for the file name.  You can
| also visit local files as a different user by specifying
| /sudo::FILE for the file name.
| See the Info node `(tramp)Filename Syntax' in the Tramp Info
| manual, for more about this.
| 
| Interactively, or if wildcards is non-nil in a call from Lisp,
| expand wildcards (if any) and visit multiple files.  You can
| suppress wildcard expansion by setting `find-file-wildcards' to nil.
| 
| To visit a file without any kind of conversion and without
| automatically choosing a major mode, use M-x find-file-literally.
`----

Bye,
Tassilo
-- 
          "Emacs is not a development tool but a way of life."
                - David Kastrup in alt.religion.emacs -





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

end of thread, other threads:[~2009-02-16  8:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-16  3:04 check if these is a buffer to a file Kiwon Um
2009-02-16  3:50 ` Andy Stewart
     [not found] ` <mailman.832.1234756520.31690.help-gnu-emacs@gnu.org>
2009-02-16  4:07   ` Kiwon Um
2009-02-16  5:26   ` Jason Rumney
2009-02-16  8:03 ` Tassilo Horn

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.