all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to join most buffer in one buffer
@ 2012-09-07  7:50 lap7619
  2012-09-07  8:30 ` Eli Zaretskii
  2012-09-07  8:30 ` Peter Dyballa
  0 siblings, 2 replies; 7+ messages in thread
From: lap7619 @ 2012-09-07  7:50 UTC (permalink / raw)
  To: help-gnu-emacs

I need to join most buffer (text files) in a buffer... but every buffer has own coding-system (utf-8-dos, utf-8-unix, etc.):

a.txt (utf-8) + b.txt (raw) + ... = SUM.txt

How to do?
THANX in ADVANCE!


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

* Re: How to join most buffer in one buffer
  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
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2012-09-07  8:30 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 7 Sep 2012 00:50:03 -0700 (PDT)
> From: lap7619@yahoo.it
> 
> I need to join most buffer (text files) in a buffer... but every buffer has own coding-system (utf-8-dos, utf-8-unix, etc.):
> 
> a.txt (utf-8) + b.txt (raw) + ... = SUM.txt
> 
> How to do?

You should be able to do that as if they all had the same encoding.
When saving the result, select an encoding that supports all of the
characters, such as UTF-8:

   C-x RET c UTF-8 RET C-x C-s



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

* Re: How to join most buffer in one buffer
  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>
  1 sibling, 2 replies; 7+ messages in thread
From: Peter Dyballa @ 2012-09-07  8:30 UTC (permalink / raw)
  To: lap7619; +Cc: help-gnu-emacs


Am 07.09.2012 um 09:50 schrieb lap7619@yahoo.it:

> I need to join most buffer (text files) in a buffer... but every buffer has own coding-system (utf-8-dos, utf-8-unix, etc.):

Convert the files to one encoding and then use cat to concatenate them.

In GNU Emacs you could open the first file in a buffer and save the buffer with the final  encoding to a new file. Now you can open the other files, copy their contents (maybe into registers), and finally paste them into the target buffer. This way the different encodings will be automatically adapted to that of the target buffer.

A pro grammatical solution is also possible…

--
Greetings

  Pete

Without vi there is only GNU Emacs




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

* Re: How to join most buffer in one buffer
  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>
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2012-09-07  8:52 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Peter Dyballa <Peter_Dyballa@Web.DE>
> Date: Fri, 7 Sep 2012 10:30:56 +0200
> Cc: help-gnu-emacs@gnu.org
> 
> Convert the files to one encoding and then use cat to concatenate them.

Too complicated.

> In GNU Emacs you could open the first file in a buffer and save the buffer with the final  encoding to a new file. Now you can open the other files, copy their contents (maybe into registers), and finally paste them into the target buffer. This way the different encodings will be automatically adapted to that of the target 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.

If this doesn't work for you, please report the details.  I just tried
in Emacs 24.2, and it does work.



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

* Re: How to join most buffer in one buffer
       [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
  0 siblings, 2 replies; 7+ messages in thread
From: twiki @ 2012-09-07  9:06 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: help-gnu-emacs

> 
> 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?


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

* Re: How to join most buffer in one buffer
  2012-09-07  9:06     ` twiki
@ 2012-09-07 10:15       ` Eli Zaretskii
  2012-09-07 13:42       ` Doug Lewan
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2012-09-07 10:15 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 7 Sep 2012 02:06:42 -0700 (PDT)
> From: twiki <lap7619@yahoo.it>
> Cc: help-gnu-emacs@gnu.org
> Injection-Date: Fri, 07 Sep 2012 09:06:42 +0000
> 
> > 
> > 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!

Where does the list of file names come from?  You cannot automate
this unless the file names can be known to Emacs in some way.

> 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?

Use a coding cookie.



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

* RE: How to join most buffer in one buffer
  2012-09-07  9:06     ` twiki
  2012-09-07 10:15       ` Eli Zaretskii
@ 2012-09-07 13:42       ` Doug Lewan
  1 sibling, 0 replies; 7+ messages in thread
From: Doug Lewan @ 2012-09-07 13:42 UTC (permalink / raw)
  To: twiki, help-gnu-emacs@gnu.org; +Cc: help-gnu-emacs@gnu.org

[-- 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 --]

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

end of thread, other threads:[~2012-09-07 13:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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.