GNU bug report logs -
#1939
suggestion: adding read-line function to elisp
Previous Next
Reported by: xah lee <xah <at> xahlee.org>
Date: Sat, 17 Jan 2009 18:20:02 UTC
Severity: wishlist
Done: Chong Yidong <cyd <at> stupidchicken.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1939 in the body.
You can then email your comments to 1939 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1939
; Package
emacs
.
(Sat, 17 Jan 2009 18:20:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
xah lee <xah <at> xahlee.org>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Sat, 17 Jan 2009 18:20:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
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/
☄
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1939
; Package
emacs
.
(Sun, 18 Jan 2009 05:55:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juanma Barranquero <lekktu <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Sun, 18 Jan 2009 05:55:05 GMT)
Full text and
rfc822 format available.
Message #10 received at 1939 <at> emacsbugs.donarmstrong.com (full text, mbox):
On Sat, Jan 17, 2009 at 19:13, xah lee <xah <at> xahlee.org> wrote:
> 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.
Getting lines as list is much less frequent in elisp. The reason is
that is much more flexible (and faster) to manipulate text in a buffer
than as a collection of strings.
So in most cases, using `with-temp-buffer' (as in your read-lines
function) is the Right Thing To Do.
Juanma
Severity set to `wishlist' from `normal'
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> emacsbugs.donarmstrong.com
.
(Sun, 18 Jan 2009 20:30:04 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to xah lee <xah <at> xahlee.org>
Request was from
Chong Yidong <cyd <at> stupidchicken.com>
to
control <at> emacsbugs.donarmstrong.com
.
(Mon, 19 Jan 2009 03:20:04 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> emacsbugs.donarmstrong.com
.
(Mon, 16 Feb 2009 15:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 16 years and 186 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.