[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to join most buffer in one buffer

From: Doug Lewan
Subject: RE: How to join most buffer in one buffer
Date: Fri, 7 Sep 2012 13:42:33 +0000

Here's a little hack that seems to do what you want.
I've attached some test data. You can test it with M-x emacs-cat RET list RET.

I'll repeat Eli Zaretskii's point: You have to know which files you want. Emacs 
won't guess. (I'd be happy to write that for you, but you wouldn't be happy 
with the result.)


(defun emacs-cat (file-containing-list)
  "Concatenate files, like cat(1), but using their different coding systems.
The given FILE-CONTAINING-LIST contains the list of files to concatenate.

1. This is not bullet proof.
   If the file you give it is not meaningful,
   then neither will be your results.

2. Emacsy considerations, like narrowing, are not taken into account."
  (interactive "fFilename containing the list? ")
  (let ((fname "emacs-cat")
        (files (delete "" (lines-in-file file-containing-list)))
        (cat-buffer (get-buffer-create "*Cat Output*")))
    (set-buffer cat-buffer)
    (mapc (lambda (fn)
            (let ((other-buffer (find-file-noselect fn t nil nil))) ; You may 
want different options here. Maybe nil nil nil or nil nil t.
              (insert-buffer other-buffer)))
    (pop-to-buffer cat-buffer)
    (message "You can save your concatenated files now.")))

(defun lines-in-file (filename)
  "Return a list of strings, each of which is one line in the given FILENAME."
  (let ((fname "lines-in-file")
      (set-buffer (find-file-noselect filename t nil nil))
      (setq lines (split-string (buffer-substring-no-properties (point-min) 
(point-max)) "[\n\r]")))


> -----Original Message-----
> From:
> [] On
> Behalf Of twiki
> Sent: Friday, 2012 September 07 05:07
> To:
> Cc:
> Subject: Re: How to join most buffer in one buffer
> >
> > This is not needed.  You should be able to just "C-x i" each file
> into
> > the same buffer, then "C-x RET c utf-8 RET C-x C-s" to SUM.txt to
> save
> > them all.
> >
> Ok... but i've 200+ files and this method is time-expensive!
> Also if I open a.txt (iso-latin1-dos) and save with:
>   C-x RET c utf-8 C-x C-s
> when Emacs (re-opened a.txt) shows again iso-latin1-dos with:
>   C-h C RET
> Suggestions?

Attachment: emacs-cat.tar
Description: emacs-cat.tar

reply via email to

[Prev in Thread] Current Thread [Next in Thread]