This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Writing text buffer line operation defuns

3 posts · 6281 views

Hello,

My job often requires me to work with long files and I often reach for emacs to do my text editing.

Many times I'd like to write functions that work on a line by line basis of a text file.
What is the process to break apart a text buffer such that the lines can be stored in an elisp list worked upon and pushed back into the buffer in place of the old lines? I'm currently writing a Common Lisp tool to do something similar but would like to duplicate the effort in elisp. :D

I suppose sometimes a list of the lines is desirable (sorting and working with the lines as a data set)
and other times just modifying line by line is handy (applying transformations to each line)

Re: Writing text buffer line operation defuns

Look at Emacs' sort.el (type "C-h f sort-lines" and click on the link there), it provides everything you need for converting text to lists and back again.

Re: Writing text buffer line operation defuns

Thanks for the tip. I'll take a peek.