unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1939: suggestion: adding read-line function to elisp
@ 2009-01-17 18:13 xah lee
  2009-01-18  5:48 ` Juanma Barranquero
       [not found] ` <mailman.5150.1232258617.26697.bug-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: xah lee @ 2009-01-17 18:13 UTC (permalink / raw)
  To: bug-gnu-emacs

summary:
i'd like to have a  read-line function in elisp, that will read a  
given file and return a list of lines.

The reason is that in almost all modern scripting langs (php, perl,  
python, ruby), there's such a function, so that users can get a list  
of lines of a file in about single line of code. Getting lines as  
list is a very frequent need.

elisp is very suitable for tasks of text processing. So, having such  
a convenience function seems appropriate.

Here's a implementation:

(defun read-lines (file)
   "Return a list of lines in FILE."
   (with-temp-buffer
     (insert-file-contents file)
     (split-string
      (buffer-substring-no-properties 1 (point-max)) "\n" t)
     )
   )

Thanks.

The thought came from a recent newsgroup discussion in comp.lang.lisp
http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/ 
761fe827c8c9ea5e/

Here's a short article for some context:

• A Ruby Illustration of Lisp Problems
   http://xahlee.org/UnixResource_dir/writ/lisp_problems_by_ruby.html

   Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-20 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-17 18:13 bug#1939: suggestion: adding read-line function to elisp xah lee
2009-01-18  5:48 ` Juanma Barranquero
     [not found] ` <mailman.5150.1232258617.26697.bug-gnu-emacs@gnu.org>
2009-01-20 18:29   ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).