Page 1 of 1

Writing text buffer line operation defuns

Posted: Tue Dec 03, 2013 10:53 pm
by Pixel_Outlaw
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

Posted: Wed Dec 04, 2013 5:03 am
by edgar-rft
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

Posted: Thu Dec 05, 2013 6:52 pm
by Pixel_Outlaw
Thanks for the tip. I'll take a peek.