Article View: gnu.emacs.sources
Article #327summarize-ls-lR.el, for sorting through large ls-lR's
From: Karl Fogel
Date: Sun, 24 Jan 1993 00:19
Date: Sun, 24 Jan 1993 00:19
47 lines
2641 bytes
2641 bytes
Here is the least useful elisp program I know of, written to
prove that no task, no matter how trivial, is too minor to warrant a
special elisp function. I needed it to sort through a large (10000+
line) ls-lR file of my hard drive. I wanted a way to sort out all
those things that were in directories named "bin" or subdirs thereof
(say, /usr/bin/X11 or something) and list just them, and then do dirs
named "etc" and subdirs, then "lib", and so on, so that I could have a
more or less complete listing of all the executable binaries on my
system, and all the libs, etc. But I didn't want to do it by hand, no
sir, I wanted the machine to do it for me. So here it is, and if
anyone out there actually uses it, I will be shocked. But, SOMEDAY,
you will be sorting through an ls-lR file, and then you'll be glad you
downloaded this. Enjoy!
-karl
(defun summarize-ls-lR (lsr-search-pat lsr-summary-buffer)
"Copies specified directories from an ls-lR file and pastes them
into specified buffer. Directories may be specified by any criterion,
but \"foo:^J\" is recommended, since ls-lR format uses that for the
basename of directories. To get dirs named \"foo\" and subdirs
thereof, search for regexp \"foo\\(:\\|/.*:\\)\"."
(interactive "sEnter summary criterion: \nsEnter buffer to paste to: ")
(save-excursion
(re-search-forward lsr-search-pat)
(beginning-of-line)
(let ((lsr-pos1 (point)))
(search-forward "\C-j\C-j")
(let ((lsr-pos2 (point)))
(let ((lsr-string (buffer-substring lsr-pos1 lsr-pos2))
(lsr-orig-buffer (current-buffer)))
(set-buffer (get-buffer-create lsr-summary-buffer))
(insert lsr-string)
(set-buffer lsr-orig-buffer))))
(summarize-ls-lR lsr-search-pat lsr-summary-buffer)))
--
Karl Fogel ("Leg of Lark") <> My institutions are not
kfogel@cs.oberlin.edu <> necessarily those of my opinions.
fogel@antares.mcs.anl.gov <>
<> Linux, the copylefted Unix for the 386/486 PC!!! <> Ask me more!!! <>
<> Linux FAQ: tsx-11.mit.edu:/pub/linux or sunsite.unc.edu:/pub/Linux <>
Technical Details
Message-ID:
<KFOGEL.93Jan23191938@occs.cs.oberlin.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!howland.reston.ans.net!sol.ctr.columbia.edu!sol.ctr.columbia.edu!kfogelShow Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.sources Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!howland.reston.ans.net!sol.ctr.columbia.edu!sol.ctr.columbia.edu!kfogel From: kfogel@occs.cs.oberlin.edu (Karl Fogel) Subject: summarize-ls-lR.el, for sorting through large ls-lR's Sender: nobody@ctr.columbia.edu Organization: Oberlin College Computer Science Date: Sun, 24 Jan 1993 00:19:38 GMT Message-ID: <KFOGEL.93Jan23191938@occs.cs.oberlin.edu> X-Posted-From: occs.cs.oberlin.edu NNTP-Posting-Host: sol.ctr.columbia.edu Lines: 47