delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/10/08/09:00:26

From: Dave Pearson <davep DOT news AT davep DOT org>
Newsgroups: comp.os.msdos.djgpp,comp.emacs,gnu.emacs.sources
Subject: Re: "shell" command in DJGPP Emacs?
Followup-To: comp.os.msdos.djgpp,comp.emacs
Date: 8 Oct 2002 12:59:28 GMT
Organization: (davep 'org)
Lines: 28
Message-ID: <slrnaq5llg.i0f.davep.news@hagbard.davep.org>
References: <3da26e84 DOT 3476875 AT news-server DOT optonline DOT net> <anu64k$mgp$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <3da2bdfe DOT 2802949 AT news-server DOT optonline DOT net> <x5ofa52m6q DOT fsf AT tupik DOT goethe DOT zz> <3da2c999 DOT 5774704 AT news-server DOT optonline DOT net>
NNTP-Posting-Host: hagbard.davep.org
X-Trace: news.demon.co.uk 1034081990 12320 158.152.34.118 (8 Oct 2002 12:59:50 GMT)
X-Complaints-To: abuse AT demon DOT net
NNTP-Posting-Date: 8 Oct 2002 12:59:28 GMT
X-URL: http://www.davep.org/
User-Agent: slrn/0.9.7.4 (Linux)
X-DDate: Sweetmorn, Day 62 of the season of Bureaucracy, Anno Mung 3168
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

* daniel gerard mcgrath <dmcg6174 AT yahoo DOT com>:

> OK!  Well, actually, I need a function that works something like this:
> 
> (count-lines-in-file FILENAME)
> 
> where FILENAME is some sort of path name, like
> "/windows/dansstuf.txt", and the result being that the number of lines
> (i.e. newline characters) in DANSSTUF.TXT (or whatever) is returned
> from the "count-lines-in-file" function.

(defun count-lines-in-file (file)
  "Count lines in FILE.

If called as an interactive command, also display the count."
  (interactive "fFile: ")
  (with-temp-buffer
    (insert-file-contents-literally file)
    (let ((count (count-lines (point-min) (point-max))))
      (when (interactive-p)
        (message "%d" count))
      count)))

-- 
Dave Pearson:                   |     lbdb.el - LBDB interface.
http://www.davep.org/           |  sawfish.el - Sawfish mode.
Emacs:                          |  uptimes.el - Record emacs uptimes.
http://www.davep.org/emacs/     | quickurl.el - Recall lists of URLs.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019