From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: xah lee Newsgroups: gmane.emacs.bugs Subject: bug#1939: suggestion: adding read-line function to elisp Date: Sat, 17 Jan 2009 10:13:51 -0800 Message-ID: <421D26F9-3257-44EE-97B0-A7276A97AD73@xahlee.org> Reply-To: xah lee , 1939@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v753.1) Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1232256769 4479 80.91.229.12 (18 Jan 2009 05:32:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Jan 2009 05:32:49 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 18 06:34:02 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LOQIJ-0007NU-Dl for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Jan 2009 06:33:59 +0100 Original-Received: from localhost ([127.0.0.1]:51721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOQH2-0006vN-CK for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Jan 2009 00:32:40 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LOFpU-0005kn-Qy for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:23:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LOFpT-0005iU-7X for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:23:32 -0500 Original-Received: from [199.232.76.173] (port=34398 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOFpT-0005iM-2f for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:23:31 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:40023) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LOFpS-0001iC-J9 for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:23:30 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0HINQXC002988; Sat, 17 Jan 2009 10:23:27 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n0HIK3lb001792; Sat, 17 Jan 2009 10:20:03 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: xah lee Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 17 Jan 2009 18:20:02 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 1939 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.1232216055513 (code B ref -1); Sat, 17 Jan 2009 18:20:02 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 17 Jan 2009 18:14:15 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0HIEBSi000507 for ; Sat, 17 Jan 2009 10:14:12 -0800 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LOFgR-00020Z-4t for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:14:11 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LOFgO-0001zz-Gq for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:14:09 -0500 Original-Received: from [199.232.76.173] (port=58889 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LOFgO-0001zw-Bo for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:14:08 -0500 Original-Received: from mout.perfora.net ([74.208.4.194]:63184) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LOFgO-0000Q0-0y for bug-gnu-emacs@gnu.org; Sat, 17 Jan 2009 13:14:08 -0500 Original-Received: from [192.168.1.2] (c-24-6-175-142.hsd1.ca.comcast.net [24.6.175.142]) by mrelay.perfora.net (node=mrus1) with ESMTP (Nemesis) id 0MKpCa-1LOFgB08RQ-0007FS; Sat, 17 Jan 2009 13:13:57 -0500 X-Mailer: Apple Mail (2.753.1) X-Provags-ID: V01U2FsdGVkX18d2wpLm1IWLEJ95u2VrRFVLkIkoztYDgiL9lv twA7QSHcOqeWoLxQ/+v1P/OutgBaP9yQT14wLz0H98bDPrk7+S oehaHOxlgslnL0a9viszg== X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sat, 17 Jan 2009 13:23:32 -0500 X-Mailman-Approved-At: Sun, 18 Jan 2009 00:32:36 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:24245 Archived-At: summary: i'd like to have a read-line function in elisp, that will read a =20 given file and return a list of lines. The reason is that in almost all modern scripting langs (php, perl, =20 python, ruby), there's such a function, so that users can get a list =20 of lines of a file in about single line of code. Getting lines as =20 list is a very frequent need. elisp is very suitable for tasks of text processing. So, having such =20 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/=20 761fe827c8c9ea5e/ Here's a short article for some context: =E2=80=A2 A Ruby Illustration of Lisp Problems http://xahlee.org/UnixResource_dir/writ/lisp_problems_by_ruby.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84=