* elisp: howto save not-visible buffer
@ 2009-04-24 14:44 Michal
2009-04-24 20:14 ` Anselm Helbig
2009-04-25 6:49 ` Nikolaj Schumacher
0 siblings, 2 replies; 4+ messages in thread
From: Michal @ 2009-04-24 14:44 UTC (permalink / raw)
To: help-gnu-emacs
Hallo,
can I save buffer that is not current one?
something like that:
(setq buf (find-file-noselect "/some/file"))
(save-buffer buf)
I see that 'save-buffer' does not get any parameter:(
best regards
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: elisp: howto save not-visible buffer
2009-04-24 14:44 elisp: howto save not-visible buffer Michal
@ 2009-04-24 20:14 ` Anselm Helbig
2009-04-25 6:49 ` Nikolaj Schumacher
1 sibling, 0 replies; 4+ messages in thread
From: Anselm Helbig @ 2009-04-24 20:14 UTC (permalink / raw)
To: help-gnu-emacs
Hi!
> Hallo,
> can I save buffer that is not current one?
>
> something like that:
> (setq buf (find-file-noselect "/some/file"))
> (save-buffer buf)
>
> I see that 'save-buffer' does not get any parameter:(
Well, then you should make the buffer you want to save the current one:
(save-excursion
(set-buffer (setq buf (find-file-noselect "/some/file")))
(save-buffer buf))
save-excursion will make sure that the current buffer is restored when
you're done.
HTH,
Anselm
--
Anselm Helbig
mailto:anselm.helbig+news2009@googlemail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: elisp: howto save not-visible buffer
2009-04-24 14:44 elisp: howto save not-visible buffer Michal
2009-04-24 20:14 ` Anselm Helbig
@ 2009-04-25 6:49 ` Nikolaj Schumacher
2009-04-27 10:45 ` Michal
1 sibling, 1 reply; 4+ messages in thread
From: Nikolaj Schumacher @ 2009-04-25 6:49 UTC (permalink / raw)
To: Michal; +Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: elisp: howto save not-visible buffer
2009-04-25 6:49 ` Nikolaj Schumacher
@ 2009-04-27 10:45 ` Michal
0 siblings, 0 replies; 4+ messages in thread
From: Michal @ 2009-04-27 10:45 UTC (permalink / raw)
To: Nikolaj Schumacher; +Cc: Michal, help-gnu-emacs
Nikolaj Schumacher <me@nschum.de> writes:
> 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.
>
Nikolaj, Thanks for Your help!
best regards,
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-27 10:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-24 14:44 elisp: howto save not-visible buffer Michal
2009-04-24 20:14 ` Anselm Helbig
2009-04-25 6:49 ` Nikolaj Schumacher
2009-04-27 10:45 ` Michal
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).