unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
Subject: Re: Opening a list of files in Emacs
Date: Thu, 12 Oct 2006 04:02:56 +0200	[thread overview]
Message-ID: <87ejtecmun.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: 1160617228.713168.214220@b28g2000cwb.googlegroups.com

venu.nayar@gmail.com writes:

> I have a file containing a list of files (full-pathname), one per line.
> How do I open this list of files from Emacs? Is there a elisp package
> to do this?

(defun text-file-contents (path)
  "Returns a list of strings, the lines in the text file at path."
  (let ((lines '()))
    (with-temp-buffer
      (insert-file-contents path)
      (goto-char 0)
      (while (< (point) (point-max))
        (push (buffer-substring-no-properties
               (progn (beginning-of-line) (point))
               (progn (end-of-line)       (point))) lines)
        (forward-line 1)))
    (nreverse lines)))


(defun find-file-of-files (filename)
  (interactive (find-file-read-args "Find file of files: " nil))
  (dolist (file (text-file-contents filename)) (find-file file)))


Perhaps:

(defun string-trim (bag string)
  (let* ((margin (format "[%s]*" (regexp-quote bag)))
         (trimer (format "\\`%s\\(\\(.\\|\n\\)*?\\)%s\\'" margin margin)))
    (replace-regexp-in-string  trimer "\\1" string)))


(defun find-file-of-files (filename)
  (interactive (find-file-read-args "Find file of files: " nil))
  (dolist (file 
          (mapcan (lambda (path) 
                    (setf path (string-trim " \t" path))
                    (if (or (string= "" path)     ; empty lines
                            (= ?# (aref path 0))) ; comments
                        '()
                        (list path)))
                   (text-file-contents "file-of-pathnames")))
    (find-file file)))
  


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.

  reply	other threads:[~2006-10-12  2:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-12  1:40 Opening a list of files in Emacs venu.nayar
2006-10-12  2:02 ` Pascal Bourguignon [this message]
2006-10-12 15:25   ` CloudStrife
2006-10-12  2:21 ` ChunYe Wang
2006-10-12  2:22   ` ChunYe Wang
2006-10-13 21:37     ` Dieter Wilhelm
     [not found]     ` <mailman.8132.1160776207.9609.help-gnu-emacs@gnu.org>
2006-10-14  3:50       ` Fang lun gang
2006-10-16 15:42         ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ejtecmun.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).