all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Doug Lewan <dougl@shubertticketing.com>
To: twiki <lap7619@yahoo.it>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: How to join most buffer in one buffer
Date: Fri, 7 Sep 2012 13:42:33 +0000	[thread overview]
Message-ID: <155DEC68569B714B86C2C7075F5EDA98268FF128@DAKIYA1.pegasus.local> (raw)
In-Reply-To: <3340ed59-7d18-40d5-9c84-dd26f16370cf@googlegroups.com>

[-- Attachment #1: Type: text/plain, Size: 2572 bytes --]

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.)

,Doug

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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.

CAVEATS: 
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)
    (erase-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)))
	  files)
    (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")
	(buffer-contents)
	(lines)
	)
    (save-excursion
      (set-buffer (find-file-noselect filename t nil nil))
      (setq lines (split-string (buffer-substring-no-properties (point-min) (point-max)) "[\n\r]")))
    lines))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


> -----Original Message-----
> From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org
> [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On
> Behalf Of twiki
> Sent: Friday, 2012 September 07 05:07
> To: help-gnu-emacs@gnu.org
> Cc: help-gnu-emacs@gnu.org
> 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 #2: emacs-cat.tar --]
[-- Type: application/x-tar, Size: 10240 bytes --]

      parent reply	other threads:[~2012-09-07 13:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07  7:50 How to join most buffer in one buffer lap7619
2012-09-07  8:30 ` Eli Zaretskii
2012-09-07  8:30 ` Peter Dyballa
2012-09-07  8:52   ` Eli Zaretskii
     [not found]   ` <mailman.8292.1347007973.855.help-gnu-emacs@gnu.org>
2012-09-07  9:06     ` twiki
2012-09-07 10:15       ` Eli Zaretskii
2012-09-07 13:42       ` Doug Lewan [this message]

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

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

  git send-email \
    --in-reply-to=155DEC68569B714B86C2C7075F5EDA98268FF128@DAKIYA1.pegasus.local \
    --to=dougl@shubertticketing.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=lap7619@yahoo.it \
    /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.
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.