* How to programmatically save a buffer?
@ 2015-11-17 22:07 Marcin Borkowski
2015-11-17 22:21 ` Jorge A. Alfaro-Murillo
0 siblings, 1 reply; 5+ messages in thread
From: Marcin Borkowski @ 2015-11-17 22:07 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi there,
as part of a function of mine, I want to save a buffer. However, I do
not want any messages logged (as save-buffer does). I found this in the
manual:
--8<---------------cut here---------------start------------->8---
You can write the contents of a buffer, or part of a buffer, directly to
a file on disk using the ‘append-to-file’ and ‘write-region’ functions.
Don’t use these functions to write to files that are being visited; that
could cause confusion in the mechanisms for visiting.
--8<---------------cut here---------------end--------------->8---
Why shouldn't I use `write-region'?
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to programmatically save a buffer?
2015-11-17 22:07 How to programmatically save a buffer? Marcin Borkowski
@ 2015-11-17 22:21 ` Jorge A. Alfaro-Murillo
2015-11-19 22:13 ` Marcin Borkowski
0 siblings, 1 reply; 5+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-11-17 22:21 UTC (permalink / raw)
To: help-gnu-emacs
Hi Marcin,
Marcin Borkowski writes:
> as part of a function of mine, I want to save a buffer.
> However, I do not want any messages logged (as save-buffer
> does).
If you do something like:
#+BEGIN_SRC emacs-lisp
(let (message-log-max)
...
(save-buffer)
...
)
#+END_SRC
then message-log-max is nil while save-buffer is executed and so
it doesn't log the message.
--
Jorge.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to programmatically save a buffer?
2015-11-17 22:21 ` Jorge A. Alfaro-Murillo
@ 2015-11-19 22:13 ` Marcin Borkowski
2015-11-19 22:21 ` Jorge A. Alfaro-Murillo
0 siblings, 1 reply; 5+ messages in thread
From: Marcin Borkowski @ 2015-11-19 22:13 UTC (permalink / raw)
To: Jorge A. Alfaro-Murillo; +Cc: help-gnu-emacs
On 2015-11-17, at 23:21, Jorge A. Alfaro-Murillo <jorge.alfaro-murillo@yale.edu> wrote:
> Hi Marcin,
>
> Marcin Borkowski writes:
>
>> as part of a function of mine, I want to save a buffer.
>> However, I do not want any messages logged (as save-buffer
>> does).
>
> If you do something like:
>
> #+BEGIN_SRC emacs-lisp
> (let (message-log-max)
> ...
> (save-buffer)
> ...
> )
> #+END_SRC
>
> then message-log-max is nil while save-buffer is executed and so
> it doesn't log the message.
Thanks, that's /almost/ it - but it still shows the message in the echo
area... How to avoid that?
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to programmatically save a buffer?
2015-11-19 22:13 ` Marcin Borkowski
@ 2015-11-19 22:21 ` Jorge A. Alfaro-Murillo
0 siblings, 0 replies; 5+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-11-19 22:21 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski writes:
> Jorge A. Alfaro-Murillo writes:
>
>> Marcin Borkowski writes:
>>
>>> as part of a function of mine, I want to save a buffer.
>>> However, I do not want any messages logged (as save-buffer
>>> does).
>>
>> If you do something like:
>>
>> #+BEGIN_SRC emacs-lisp
>> (let (message-log-max)
>> ... (save-buffer) ... )
>> #+END_SRC
>>
>> then message-log-max is nil while save-buffer is executed and
>> so it doesn't log the message.
>
> Thanks, that's /almost/ it - but it still shows the message in
> the echo area... How to avoid that?
#+BEGIN_SRC emacs-lisp
(let ((inhibit-message t)
message-log-max)
...
(save-buffer)
...
)
#+END_SRC
Best,
--
Jorge.
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.108.1447798057.31583.help-gnu-emacs@gnu.org>]
* Re: How to programmatically save a buffer?
[not found] <mailman.108.1447798057.31583.help-gnu-emacs@gnu.org>
@ 2015-11-17 22:41 ` Pascal J. Bourguignon
0 siblings, 0 replies; 5+ messages in thread
From: Pascal J. Bourguignon @ 2015-11-17 22:41 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> Hi there,
>
> as part of a function of mine, I want to save a buffer. However, I do
> not want any messages logged (as save-buffer does). I found this in the
> manual:
>
> You can write the contents of a buffer, or part of a buffer, directly to
> a file on disk using the ‘append-to-file’ and ‘write-region’ functions.
> Don’t use these functions to write to files that are being visited; that
> could cause confusion in the mechanisms for visiting.
>
> Why shouldn't I use `write-region'?
Because find-file doesn't necessarily put the file contents in the
buffer, but some "formatted" or "extracted" version of if.
You may try basic-save-buffer
which writes a message only if no save was needed.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-19 22:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-17 22:07 How to programmatically save a buffer? Marcin Borkowski
2015-11-17 22:21 ` Jorge A. Alfaro-Murillo
2015-11-19 22:13 ` Marcin Borkowski
2015-11-19 22:21 ` Jorge A. Alfaro-Murillo
[not found] <mailman.108.1447798057.31583.help-gnu-emacs@gnu.org>
2015-11-17 22:41 ` Pascal J. Bourguignon
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.