Writing text buffer line operation defuns

Discussion of Emacs Lisp
Post Reply
Pixel_Outlaw
Posts: 43
Joined: Mon Aug 26, 2013 9:24 pm

Writing text buffer line operation defuns

Post by Pixel_Outlaw » Tue Dec 03, 2013 10:53 pm

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)

edgar-rft
Posts: 226
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: Writing text buffer line operation defuns

Post by edgar-rft » Wed Dec 04, 2013 5:03 am

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.

Pixel_Outlaw
Posts: 43
Joined: Mon Aug 26, 2013 9:24 pm

Re: Writing text buffer line operation defuns

Post by Pixel_Outlaw » Thu Dec 05, 2013 6:52 pm

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

Post Reply