* How to write a string to a file inside emacs ?
@ 2007-10-23 16:26 gnuist006
2007-10-23 16:30 ` gnuist006
0 siblings, 1 reply; 14+ messages in thread
From: gnuist006 @ 2007-10-23 16:26 UTC (permalink / raw)
To: help-gnu-emacs
Here is the problem:
How would you write a string to a file inside emacs ? There is the
main buffer that you are viewing called file1. Here you run a lisp
function which is supposed to write some text of the file or in a
variable to another file called file2.
I have looked and found this function:
(append-to-file START END FILENAME)
This function is only good enough to copy selected text from file1 to
file2, BUT I want a function that copies value of a string variable
str-var into file2 or some other string. Basically, I want a
generalization/modification of the command "insert" to append which
takes a filename as an argument and appends a given string over there.
I know one dirty workaround is to insert the text in file1, and then
append-to-file into file2 and then remove it from file1.
Is there a faster or cleaner approach ? This has to be done a lot and
one wants something faster than writing, copying and erasing.
append-to-buffer is an interactive compiled Lisp function in `simple'.
(append-to-buffer BUFFER START END)
Append to specified buffer the text of the region.
It is inserted into that buffer before its point.
When calling from a program, give three arguments:
BUFFER (or buffer name), START and END.
START and END specify the portion of the current buffer to be copied.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:26 How to write a string to a file inside emacs ? gnuist006
@ 2007-10-23 16:30 ` gnuist006
2007-10-23 16:42 ` gnuist006
0 siblings, 1 reply; 14+ messages in thread
From: gnuist006 @ 2007-10-23 16:30 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 23, 9:26 am, gnuist...@gmail.com wrote:
> Here is the problem:
>
> How would you write a string to a file inside emacs ? There is the
> main buffer that you are viewing called file1. Here you run a lisp
> function which is supposed to write some text of the file or in a
> variable to another file called file2.
>
> I have looked and found this function:
>
> (append-to-file START END FILENAME)
>
> This function is only good enough to copy selected text from file1 to
> file2, BUT I want a function that copies value of a string variable
> str-var into file2 or some other string. Basically, I want a
> generalization/modification of the command "insert" to append which
> takes a filename as an argument and appends a given string over there.
>
> I know one dirty workaround is to insert the text in file1, and then
> append-to-file into file2 and then remove it from file1.
>
> Is there a faster or cleaner approach ? This has to be done a lot and
> one wants something faster than writing, copying and erasing.
>
> append-to-buffer is an interactive compiled Lisp function in `simple'.
> (append-to-buffer BUFFER START END)
>
> Append to specified buffer the text of the region.
> It is inserted into that buffer before its point.
>
> When calling from a program, give three arguments:
> BUFFER (or buffer name), START and END.
> START and END specify the portion of the current buffer to be copied.
just found the write-file is based on write-region but neither solves
my problem.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:30 ` gnuist006
@ 2007-10-23 16:42 ` gnuist006
2007-10-23 16:45 ` Rainer Joswig
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: gnuist006 @ 2007-10-23 16:42 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 23, 9:30 am, gnuist...@gmail.com wrote:
> On Oct 23, 9:26 am, gnuist...@gmail.com wrote:
>
>
>
> > Here is the problem:
>
> > How would you write a string to a file inside emacs ? There is the
> > main buffer that you are viewing called file1. Here you run a lisp
> > function which is supposed to write some text of the file or in a
> > variable to another file called file2.
>
> > I have looked and found this function:
>
> > (append-to-file START END FILENAME)
>
> > This function is only good enough to copy selected text from file1 to
> > file2, BUT I want a function that copies value of a string variable
> > str-var into file2 or some other string. Basically, I want a
> > generalization/modification of the command "insert" to append which
> > takes a filename as an argument and appends a given string over there.
>
> > I know one dirty workaround is to insert the text in file1, and then
> > append-to-file into file2 and then remove it from file1.
>
> > Is there a faster or cleaner approach ? This has to be done a lot and
> > one wants something faster than writing, copying and erasing.
>
> > append-to-buffer is an interactive compiled Lisp function in `simple'.
> > (append-to-buffer BUFFER START END)
>
> > Append to specified buffer the text of the region.
> > It is inserted into that buffer before its point.
>
> > When calling from a program, give three arguments:
> > BUFFER (or buffer name), START and END.
> > START and END specify the portion of the current buffer to be copied.
>
> just found the write-file is based on write-region but neither solves
> my problem.
Kludgy feature: if START is a string, then that string is written
to the file, instead of any buffer contents, and END is ignored.
<--------It does not seem to work
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:42 ` gnuist006
@ 2007-10-23 16:45 ` Rainer Joswig
2007-10-23 17:00 ` gnuist006
` (2 more replies)
2007-10-23 17:05 ` gnuist006
2007-10-24 1:00 ` Stefan Monnier
2 siblings, 3 replies; 14+ messages in thread
From: Rainer Joswig @ 2007-10-23 16:45 UTC (permalink / raw)
To: help-gnu-emacs
In article <1193157722.974559.53510@e34g2000pro.googlegroups.com>,
gnuist006@gmail.com wrote:
Please send Emacs related questions only to an Emacs
newsgroup. comp.lang.lisp and comp.lang.scheme are
not for general questions about Emacs and not
for questions customizing Emacs with Emacs Lisp.
Thanks.
Followup-To set to gnu.emacs.help .
> On Oct 23, 9:30 am, gnuist...@gmail.com wrote:
> > On Oct 23, 9:26 am, gnuist...@gmail.com wrote:
> >
> >
> >
> > > Here is the problem:
> >
> > > How would you write a string to a file inside emacs ? There is the
> > > main buffer that you are viewing called file1. Here you run a lisp
> > > function which is supposed to write some text of the file or in a
> > > variable to another file called file2.
> >
> > > I have looked and found this function:
> >
> > > (append-to-file START END FILENAME)
> >
> > > This function is only good enough to copy selected text from file1 to
> > > file2, BUT I want a function that copies value of a string variable
> > > str-var into file2 or some other string. Basically, I want a
> > > generalization/modification of the command "insert" to append which
> > > takes a filename as an argument and appends a given string over there.
> >
> > > I know one dirty workaround is to insert the text in file1, and then
> > > append-to-file into file2 and then remove it from file1.
> >
> > > Is there a faster or cleaner approach ? This has to be done a lot and
> > > one wants something faster than writing, copying and erasing.
> >
> > > append-to-buffer is an interactive compiled Lisp function in `simple'.
> > > (append-to-buffer BUFFER START END)
> >
> > > Append to specified buffer the text of the region.
> > > It is inserted into that buffer before its point.
> >
> > > When calling from a program, give three arguments:
> > > BUFFER (or buffer name), START and END.
> > > START and END specify the portion of the current buffer to be copied.
> >
> > just found the write-file is based on write-region but neither solves
> > my problem.
>
> Kludgy feature: if START is a string, then that string is written
> to the file, instead of any buffer contents, and END is ignored.
> <--------It does not seem to work
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:45 ` Rainer Joswig
@ 2007-10-23 17:00 ` gnuist006
2007-10-24 8:45 ` Xah Lee
2007-10-24 8:49 ` Xah Lee
2 siblings, 0 replies; 14+ messages in thread
From: gnuist006 @ 2007-10-23 17:00 UTC (permalink / raw)
To: help-gnu-emacs
Sure, lets everyone do it. thx for pointing it out.
On Oct 23, 9:45 am, Rainer Joswig <jos...@lisp.de> wrote:
> In article <1193157722.974559.53...@e34g2000pro.googlegroups.com>,
>
> gnuist...@gmail.com wrote:
>
> Please send Emacs related questions only to an Emacs
> newsgroup. comp.lang.lisp and comp.lang.scheme are
> not for general questions about Emacs and not
> for questions customizing Emacs with Emacs Lisp.
>
> Thanks.
>
> Followup-To set to gnu.emacs.help .
>
> > On Oct 23, 9:30 am, gnuist...@gmail.com wrote:
> > > On Oct 23, 9:26 am, gnuist...@gmail.com wrote:
>
> > > > Here is the problem:
>
> > > > How would you write a string to a file inside emacs ? There is the
> > > > main buffer that you are viewing called file1. Here you run a lisp
> > > > function which is supposed to write some text of the file or in a
> > > > variable to another file called file2.
>
> > > > I have looked and found this function:
>
> > > > (append-to-file START END FILENAME)
>
> > > > This function is only good enough to copy selected text from file1 to
> > > > file2, BUT I want a function that copies value of a string variable
> > > > str-var into file2 or some other string. Basically, I want a
> > > > generalization/modification of the command "insert" to append which
> > > > takes a filename as an argument and appends a given string over there.
>
> > > > I know one dirty workaround is to insert the text in file1, and then
> > > > append-to-file into file2 and then remove it from file1.
>
> > > > Is there a faster or cleaner approach ? This has to be done a lot and
> > > > one wants something faster than writing, copying and erasing.
>
> > > > append-to-buffer is an interactive compiled Lisp function in `simple'.
> > > > (append-to-buffer BUFFER START END)
>
> > > > Append to specified buffer the text of the region.
> > > > It is inserted into that buffer before its point.
>
> > > > When calling from a program, give three arguments:
> > > > BUFFER (or buffer name), START and END.
> > > > START and END specify the portion of the current buffer to be copied.
>
> > > just found the write-file is based on write-region but neither solves
> > > my problem.
>
> > Kludgy feature: if START is a string, then that string is written
> > to the file, instead of any buffer contents, and END is ignored.
> > <--------It does not seem to work
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:45 ` Rainer Joswig
2007-10-23 17:00 ` gnuist006
@ 2007-10-24 8:45 ` Xah Lee
2007-10-24 8:49 ` Xah Lee
2 siblings, 0 replies; 14+ messages in thread
From: Xah Lee @ 2007-10-24 8:45 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 524 bytes --]
Please ignore Rainer Joswig's advice. He's a card-carrying member of
the Common Lisp faction.
comp.lang.lisp is for all lisps, including emacs lisp and Scheme Lisp.
Xah
xah@xahlee.org
http://xahlee.org/
On Oct 23, 9:45 am, Rainer Joswig wrote:
«
Please send Emacs related questions only to an Emacs
newsgroup. comp.lang.lisp and comp.lang.scheme are
not for general questions about Emacs and not
for questions customizing Emacs with Emacs Lisp.
Thanks.
Followup-To set to gnu.emacs.help .
»
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:45 ` Rainer Joswig
2007-10-23 17:00 ` gnuist006
2007-10-24 8:45 ` Xah Lee
@ 2007-10-24 8:49 ` Xah Lee
2007-10-24 11:05 ` Bastien
` (2 more replies)
2 siblings, 3 replies; 14+ messages in thread
From: Xah Lee @ 2007-10-24 8:49 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 738 bytes --]
WHAT A MOTHERFUCK!
I got tricked into posting into a group i didn't intend to.
People, if you are going to advice and tweak the newsgroup follow up,
start with motherfucking yourself.
I repost my original message below
-------------------------------
Please ignore Rainer Joswig's advice. He's a Common Lisp fan.
comp.lang.lisp is for all lisps, including emacs lisp.
Xah
xah@xahlee.org
http://xahlee.org/
On Oct 23, 9:45 am, Rainer Joswig wrote:
«
Please send Emacs related questions only to an Emacs
newsgroup. comp.lang.lisp and comp.lang.scheme are
not for general questions about Emacs and not
for questions customizing Emacs with Emacs Lisp.
Thanks.
Followup-To set to gnu.emacs.help .
»
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-24 8:49 ` Xah Lee
@ 2007-10-24 11:05 ` Bastien
2007-10-24 21:17 ` George Neuner
2007-10-24 22:16 ` Rainer Joswig
2 siblings, 0 replies; 14+ messages in thread
From: Bastien @ 2007-10-24 11:05 UTC (permalink / raw)
To: help-gnu-emacs
Xah Lee <xah@xahlee.org> writes:
> WHAT A MOTHERFUCK!
« Emacs is the mother of Invention. »
--
Bastien
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-24 8:49 ` Xah Lee
2007-10-24 11:05 ` Bastien
@ 2007-10-24 21:17 ` George Neuner
2007-10-24 22:16 ` Rainer Joswig
2 siblings, 0 replies; 14+ messages in thread
From: George Neuner @ 2007-10-24 21:17 UTC (permalink / raw)
To: help-gnu-emacs
On Wed, 24 Oct 2007 01:49:43 -0700, Xah Lee <xah@xahlee.org> wrote:
>WHAT A MOTHERFUCK!
>I got tricked into posting into a group i didn't intend to.
>
>People, if you are going to advice and tweak the newsgroup follow up,
>start with motherfucking yourself.
>
>I repost my original message below
>-------------------------------
>
>Please ignore Rainer Joswig's advice. He's a Common Lisp fan.
>
>comp.lang.lisp is for all lisps, including emacs lisp.
>
> Xah
> xah@xahlee.org
> http://xahlee.org/
WATCH YOUR LANGUAGE! I'm not going to warn you again.
George
--
for email reply remove "/" from address
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-24 8:49 ` Xah Lee
2007-10-24 11:05 ` Bastien
2007-10-24 21:17 ` George Neuner
@ 2007-10-24 22:16 ` Rainer Joswig
2 siblings, 0 replies; 14+ messages in thread
From: Rainer Joswig @ 2007-10-24 22:16 UTC (permalink / raw)
To: help-gnu-emacs
In article <1193215783.299038.58650@q3g2000prf.googlegroups.com>,
Xah Lee <xah@xahlee.org> wrote:
> WHAT A MOTHERFUCK!
> I got tricked into posting into a group i didn't intend to.
Bla bla.
>
> People, if you are going to advice and tweak the newsgroup follow up,
> start with motherfucking yourself.
>
> I repost my original message below
> -------------------------------
>
> Please ignore Rainer Joswig's advice. He's a Common Lisp fan.
Frogshit.
> comp.lang.lisp is for all lisps, including emacs lisp.
If I have a Scheme question, I use comp.lang.scheme.
If I have a Logo question, I use comp.lang.logo.
If I have an Emacs question, I use one of the
multitude of Emacs newsgroups.
Comp.lang.lisp is mostly used for general Lisp discussion.
Specific questions about implementations and their usage
are best asked on their mailing lists or their newsgroups.
Newbies may not know the right place to ask, so
they often get the pointer to the right place.
comp.lang.lisp is not about customizing GNU Emacs.
If you want to post about customizing Emacs,
do it in an Emacs newsgroup. All the stuff
you have posted is Emacs specific and not of
general interest (image tags in Emacs).
GNU Emacs has a special Lisp dialect for customization
and its own libraries.
If you want to post about a GENERAL Lisp topic (which might
include questions about all Lisp dialects), post in
comp.lang.lisp . But, best post to the most
specific newsgroup to get the most qualified answer.
Your own postings about customizing Emacs are a typical
example for an unwanted cross-posting. Please stop
that. They may be useful for Emacs users, but there
is little general Lisp content.
Should every comp.lang.logo post be cross-posted to comp.lang.lisp,
just because Logo is a Lisp dialect? I'd hope not.
>
> Xah
> xah@xahlee.org
> http://xahlee.org/
>
>
>
> On Oct 23, 9:45 am, Rainer Joswig wrote:
> ?
> Please send Emacs related questions only to an Emacs
> newsgroup. comp.lang.lisp and comp.lang.scheme are
> not for general questions about Emacs and not
> for questions customizing Emacs with Emacs Lisp.
>
> Thanks.
> Followup-To set to gnu.emacs.help .
> ?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:42 ` gnuist006
2007-10-23 16:45 ` Rainer Joswig
@ 2007-10-23 17:05 ` gnuist006
2007-10-24 1:00 ` Stefan Monnier
2 siblings, 0 replies; 14+ messages in thread
From: gnuist006 @ 2007-10-23 17:05 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 23, 9:42 am, gnuist...@gmail.com wrote:
> On Oct 23, 9:30 am, gnuist...@gmail.com wrote:
>
>
>
> > On Oct 23, 9:26 am, gnuist...@gmail.com wrote:
>
> > > Here is the problem:
>
> > > How would you write a string to a file inside emacs ? There is the
> > > main buffer that you are viewing called file1. Here you run a lisp
> > > function which is supposed to write some text of the file or in a
> > > variable to another file called file2.
>
> > > I have looked and found this function:
>
> > > (append-to-file START END FILENAME)
>
> > > This function is only good enough to copy selected text from file1 to
> > > file2, BUT I want a function that copies value of a string variable
> > > str-var into file2 or some other string. Basically, I want a
> > > generalization/modification of the command "insert" to append which
> > > takes a filename as an argument and appends a given string over there.
>
> > > I know one dirty workaround is to insert the text in file1, and then
> > > append-to-file into file2 and then remove it from file1.
>
> > > Is there a faster or cleaner approach ? This has to be done a lot and
> > > one wants something faster than writing, copying and erasing.
>
> > > append-to-buffer is an interactive compiled Lisp function in `simple'.
> > > (append-to-buffer BUFFER START END)
>
> > > Append to specified buffer the text of the region.
> > > It is inserted into that buffer before its point.
>
> > > When calling from a program, give three arguments:
> > > BUFFER (or buffer name), START and END.
> > > START and END specify the portion of the current buffer to be copied.
>
> > just found the write-file is based on write-region but neither solves
> > my problem.
>
> Kludgy feature: if START is a string, then that string is written
> to the file, instead of any buffer contents, and END is ignored.
> <--------It does not seem to work
Also, I might add that I canot make use of a macro feature inside a
lisp function and therefore, I cant use something like find-file,
unless it is transparent.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-23 16:42 ` gnuist006
2007-10-23 16:45 ` Rainer Joswig
2007-10-23 17:05 ` gnuist006
@ 2007-10-24 1:00 ` Stefan Monnier
2007-10-24 3:17 ` gnuist006
2 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2007-10-24 1:00 UTC (permalink / raw)
To: help-gnu-emacs
> Kludgy feature: if START is a string, then that string is written
> to the file, instead of any buffer contents, and END is ignored.
> <--------It does not seem to work
I'd be happy to help, but I need more info than "does not seem to work".
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-24 1:00 ` Stefan Monnier
@ 2007-10-24 3:17 ` gnuist006
2007-10-24 14:15 ` Stefan Monnier
0 siblings, 1 reply; 14+ messages in thread
From: gnuist006 @ 2007-10-24 3:17 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 23, 6:00 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > Kludgy feature: if START is a string, then that string is written
> > to the file, instead of any buffer contents, and END is ignored.
> > <--------It does not seem to work
>
> I'd be happy to help, but I need more info than "does not seem to work".
>
> Stefan
Can you make any of these work? I tried the non-kludge feature,
which works and its not the path name. There is some debugger
error which i cant understand.
(write-region "astring" 2 "file2" APPEND)
(write-region "astring" "file2" APPEND)
(write-region "astring" "file2" )
(write-region "astring" 2 "file2" )
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to write a string to a file inside emacs ?
2007-10-24 3:17 ` gnuist006
@ 2007-10-24 14:15 ` Stefan Monnier
0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2007-10-24 14:15 UTC (permalink / raw)
To: help-gnu-emacs
> Can you make any of these work? I tried the non-kludge feature,
> which works and its not the path name. There is some debugger
> error which i cant understand.
> (write-region "astring" 2 "file2" APPEND)
Why 2?
> (write-region "astring" "file2" APPEND)
You forgot the END argument.
> (write-region "astring" "file2" )
Same here.
> (write-region "astring" 2 "file2" )
Again, why 2?
I use (write-region "foo" nil "/tmp/toto") and it works dandy.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-10-24 22:16 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-23 16:26 How to write a string to a file inside emacs ? gnuist006
2007-10-23 16:30 ` gnuist006
2007-10-23 16:42 ` gnuist006
2007-10-23 16:45 ` Rainer Joswig
2007-10-23 17:00 ` gnuist006
2007-10-24 8:45 ` Xah Lee
2007-10-24 8:49 ` Xah Lee
2007-10-24 11:05 ` Bastien
2007-10-24 21:17 ` George Neuner
2007-10-24 22:16 ` Rainer Joswig
2007-10-23 17:05 ` gnuist006
2007-10-24 1:00 ` Stefan Monnier
2007-10-24 3:17 ` gnuist006
2007-10-24 14:15 ` Stefan Monnier
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.