[Top][All Lists]

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

How to write a string to a file inside emacs ?

From: gnuist006
Subject: How to write a string to a file inside emacs ?
Date: Tue, 23 Oct 2007 16:26:46 -0000
User-agent: G2/1.0

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.

reply via email to

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