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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp: howto save not-visible buffer


From: Nikolaj Schumacher
Subject: Re: elisp: howto save not-visible buffer
Date: Sat, 25 Apr 2009 08:49:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (darwin)

Michal <rabbitko@tenbit.pl> wrote:

>  can I save buffer that is not current one?
>
> something like that:
> (setq buf (find-file-noselect "/some/file"))
> (save-buffer buf)

(with-current-buffer (find-file-noselect "/some/file"))
  (save-buffer))

But what you really want to do is probably:

(let ((buf (find-buffer-visiting "/some-file")))
  (when buf
    (with-current-buffer buf
      (save-buffer))))

Because you probably don't want to find the file if it isn't already
open.

regards,
Nikolaj Schumacher




reply via email to

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