all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Opening a list of files in Emacs
@ 2006-10-12  1:40 venu.nayar
  2006-10-12  2:02 ` Pascal Bourguignon
  2006-10-12  2:21 ` ChunYe Wang
  0 siblings, 2 replies; 8+ messages in thread
From: venu.nayar @ 2006-10-12  1:40 UTC (permalink / raw)


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?

Thanks,
Venu Nayar

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening a list of files in Emacs
  2006-10-12  1:40 Opening a list of files in Emacs venu.nayar
@ 2006-10-12  2:02 ` Pascal Bourguignon
  2006-10-12 15:25   ` CloudStrife
  2006-10-12  2:21 ` ChunYe Wang
  1 sibling, 1 reply; 8+ messages in thread
From: Pascal Bourguignon @ 2006-10-12  2:02 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening a list of files in Emacs
  2006-10-12  1:40 Opening a list of files in Emacs venu.nayar
  2006-10-12  2:02 ` Pascal Bourguignon
@ 2006-10-12  2:21 ` ChunYe Wang
  2006-10-12  2:22   ` ChunYe Wang
  1 sibling, 1 reply; 8+ messages in thread
From: ChunYe Wang @ 2006-10-12  2:21 UTC (permalink / raw)


venu.nayar@gmail.com writes:

M-x query-replace-regexp-eval <RET> 
    .* <RET> 
    (format "(find %S)" (match-string 0)) <RET>

M-x eval-buffer

> 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?
> 
> Thanks,
> Venu Nayar
> 

-- 
Best Regards
ChunYe Wang

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening a list of files in Emacs
  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>
  0 siblings, 2 replies; 8+ messages in thread
From: ChunYe Wang @ 2006-10-12  2:22 UTC (permalink / raw)


"ChunYe Wang" <ext-chunye.wang@nokia.com> writes:
sorry for typos.

> venu.nayar@gmail.com writes:
> 
> M-x query-replace-regexp-eval <RET> 
>     .* <RET> 
>     (format "(find %S)" (match-string 0)) <RET>
      (format "(find-file %S)" (match-string 0)) <RET>
> 
> M-x eval-buffer
> 
> > 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?
> > 
> > Thanks,
> > Venu Nayar
> > 
> 
> -- 
> Best Regards
> ChunYe Wang

-- 
Best Regards
ChunYe Wang

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening a list of files in Emacs
  2006-10-12  2:02 ` Pascal Bourguignon
@ 2006-10-12 15:25   ` CloudStrife
  0 siblings, 0 replies; 8+ messages in thread
From: CloudStrife @ 2006-10-12 15:25 UTC (permalink / raw)


Pascal,
Wont the following suffice?
M-x find-file-at-point <RET>
<RET>
Wont it do the same thing as your script or is your script different.
As i am new to emacs and hardly know any elisp... can u be simple in
explaining?
Cloud

On Oct 12, 7:02 am, Pascal Bourguignon <p...@informatimago.com> wrote:
> venu.na...@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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening a list of files in Emacs
  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>
  1 sibling, 0 replies; 8+ messages in thread
From: Dieter Wilhelm @ 2006-10-13 21:37 UTC (permalink / raw)
  Cc: help-gnu-emacs

"ChunYe Wang" <ext-chunye.wang@nokia.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?
>
>> venu.nayar@gmail.com writes:
>> 
>> M-x query-replace-regexp-eval <RET> 
>>     .* <RET> 
>       (format "(find-file %S)" (match-string 0)) <RET>
>> 
>> M-x eval-buffer

Another idea is:

M-x query-replace-regexp-eval <RET>
  .* <RET>
  (find-file-noselect \0)

or maybe just

cat file_list|xargs emacs  

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening a list of files in Emacs
       [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
  0 siblings, 1 reply; 8+ messages in thread
From: Fang lun gang @ 2006-10-14  3:50 UTC (permalink / raw)


I would prefer apply M-x ffap on each line of the file.
Define a keyboard macro for that operation would be even better.

>>>>> "Dieter" == Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:

    Dieter> "ChunYe Wang" <ext-chunye.wang@nokia.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?
    >> 
    >>> venu.nayar@gmail.com writes:
    >>> 
    >>> M-x query-replace-regexp-eval <RET> .* <RET>
    >> (format "(find-file %S)" (match-string 0)) <RET>
    >>> 
    >>> M-x eval-buffer

    Dieter> Another idea is:

    Dieter> M-x query-replace-regexp-eval <RET> .* <RET> (find-file-noselect \0)

    Dieter> or maybe just

    Dieter> cat file_list|xargs emacs

    Dieter> -- Best wishes

    Dieter>     H. Dieter Wilhelm Darmstadt, Germany



-- 
Regards,
Fang lun gang

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening a list of files in Emacs
  2006-10-14  3:50       ` Fang lun gang
@ 2006-10-16 15:42         ` Kevin Rodgers
  0 siblings, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2006-10-16 15:42 UTC (permalink / raw)


Fang lun gang wrote:
> I would prefer apply M-x ffap on each line of the file.
> Define a keyboard macro for that operation would be even better.

Good idea:

C-x h		; mark-whole-buffer
C-x (		; kmacro-start-macro
M-x ffap RET RET
C-x b RET	; switch-to-buffer
C-x )		; kmacro-end-macro
C-n		; next-line
C-x C-k r	; apply-macro-to-region-lines

-- 
Kevin

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-10-16 15:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-12  1:40 Opening a list of files in Emacs venu.nayar
2006-10-12  2:02 ` Pascal Bourguignon
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.