all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Trouble getting archives to load as archives
@ 2008-07-03 22:59 Davin Pearson
  2008-07-04  5:38 ` Thierry Volpiatto
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Davin Pearson @ 2008-07-03 22:59 UTC (permalink / raw)
  To: help-gnu-emacs

The following code works for Emacs Version 20.7 and 21.3
to load archive files as archives:

(setq auto-mode-alist
      (cons '("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode)
            auto-mode-alist))

I tried the following code but it only works on ZIP files:

(add-hook 'find-file-hooks 'my-archive-hook)
(defun my-archive-hook ()
  (when (or (string-match "\\.zip$" (buffer-name))
            (string-match "\\.tar$" (buffer-name))
            (string-match "\\.gz$"  (buffer-name)))
    (archive-mode 1)
    ))

So my question is this: how do I get archive-mode to display archives
correctly for TAR and GZ files?


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

* Re: Trouble getting archives to load as archives
  2008-07-03 22:59 Trouble getting archives to load as archives Davin Pearson
@ 2008-07-04  5:38 ` Thierry Volpiatto
  2008-07-05  1:37   ` Davin Pearson
  2008-07-04 21:57 ` Peter Dyballa
       [not found] ` <mailman.14225.1215208751.18990.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 14+ messages in thread
From: Thierry Volpiatto @ 2008-07-04  5:38 UTC (permalink / raw)
  To: Davin Pearson; +Cc: help-gnu-emacs

Davin Pearson <davin.pearson@gmail.com> writes:

> The following code works for Emacs Version 20.7 and 21.3
> to load archive files as archives:
>
> (setq auto-mode-alist
>       (cons '("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode)
>             auto-mode-alist))
>
> I tried the following code but it only works on ZIP files:
>
> (add-hook 'find-file-hooks 'my-archive-hook)
> (defun my-archive-hook ()
>   (when (or (string-match "\\.zip$" (buffer-name))
>             (string-match "\\.tar$" (buffer-name))
>             (string-match "\\.gz$"  (buffer-name)))
>     (archive-mode 1)
>     ))
>
> So my question is this: how do I get archive-mode to display archives
> correctly for TAR and GZ files?
>
Hi,
an other solution is to use avfs, with that you can open any archives on
read/write mode just as any directory in dired.
So just install avfs and set fuse in your kernel (and install fuse)
I use this code to use it in emacs:

,----[ avfs in dired ]
| (defun tv-dired-browse-archive ()
|   "This function use avfs and fuse, so be sure
| to have these programs and modules installed on your system"
|   (interactive)
|   (let ((file-at-point (dired-get-filename)))
|     (if (or (equal (file-name-extension file-at-point) "gz")
|             (equal (file-name-extension file-at-point) "bz2")
|             (equal (file-name-extension file-at-point) "zip"))
|         (progn
|           (when (not (cddr (directory-files "~/.avfs")))
|             (shell-command "mountavfs"))
|           (find-file (concat "~/.avfs" file-at-point "#")))
|       (find-file file-at-point))))
| (define-key dired-mode-map (kbd "z") 'tv-dired-browse-archive)
`----

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




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

* Re: Trouble getting archives to load as archives
  2008-07-03 22:59 Trouble getting archives to load as archives Davin Pearson
  2008-07-04  5:38 ` Thierry Volpiatto
@ 2008-07-04 21:57 ` Peter Dyballa
       [not found] ` <mailman.14225.1215208751.18990.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 14+ messages in thread
From: Peter Dyballa @ 2008-07-04 21:57 UTC (permalink / raw)
  To: Davin Pearson; +Cc: help-gnu-emacs


Am 04.07.2008 um 00:59 schrieb Davin Pearson:

> (setq auto-mode-alist
>       (cons '("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode)
>             auto-mode-alist))

Using

	(add-to-list 'auto-mode-alist '("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\ 
\'" . archive-mode))

should put your additions atop of the old entries. I've also seen  
statements similiar to this

	(setq auto-mode-alist
	  (append
	    '(("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode)
	  auto-mode-alist)))


The documentation on auto-mode-alist emphasises:

	The extensions whose FUNCTION is `archive-mode' should also
	appear in `auto-coding-alist' with `no-conversion' coding system.

which should be fulfilled for your file types. Anyway, in my Emacsen  
I have defined in auto-mode-alist:

  ("\\.\\(arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\)\\'" .  
archive-mode)
  ("\\.\\(ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\)\\'" .  
archive-mode)

Are these too many members?

--
Greetings

   Pete

A child of five could understand this!  Fetch me a child of five.






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

* Re: Trouble getting archives to load as archives
       [not found] ` <mailman.14225.1215208751.18990.help-gnu-emacs@gnu.org>
@ 2008-07-05  1:32   ` Davin Pearson
  2008-07-05  2:23     ` Bernardo Bacic
  0 siblings, 1 reply; 14+ messages in thread
From: Davin Pearson @ 2008-07-05  1:32 UTC (permalink / raw)
  To: help-gnu-emacs

On Jul 5, 9:57 am, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
>   ("\\.\\(arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\)\\'" .
> archive-mode)
>   ("\\.\\(ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\)\\'" .
> archive-mode)

Trouble is that this code doesn't work for TAR or GZ files which I am
trying to get online.


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

* Re: Trouble getting archives to load as archives
  2008-07-04  5:38 ` Thierry Volpiatto
@ 2008-07-05  1:37   ` Davin Pearson
  2008-07-06 10:59     ` Thierry Volpiatto
  0 siblings, 1 reply; 14+ messages in thread
From: Davin Pearson @ 2008-07-05  1:37 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: help-gnu-emacs

2008/7/4 Thierry Volpiatto <thierry.volpiatto@gmail.com>:
> an other solution is to use avfs, with that you can open any archives on
> read/write mode just as any directory in dired.
> So just install avfs and set fuse in your kernel (and install fuse)
> I use this code to use it in emacs:
>
> ,----[ avfs in dired ]
> | (defun tv-dired-browse-archive ()
> |   "This function use avfs and fuse, so be sure
> | to have these programs and modules installed on your system"
> |   (interactive)
> |   (let ((file-at-point (dired-get-filename)))
> |     (if (or (equal (file-name-extension file-at-point) "gz")
> |             (equal (file-name-extension file-at-point) "bz2")
> |             (equal (file-name-extension file-at-point) "zip"))
> |         (progn
> |           (when (not (cddr (directory-files "~/.avfs")))
> |             (shell-command "mountavfs"))
> |           (find-file (concat "~/.avfs" file-at-point "#")))
> |       (find-file file-at-point))))
> | (define-key dired-mode-map (kbd "z") 'tv-dired-browse-archive)
> `----

Are you sure that it is worth the trouble installing AVS?

Have you got AVS installed on your O/S?

Are you using Linux or Windows XP? I am using XP.

-- 
Sincerely and kindest regards, Davin.
Davin Pearson http://www.davinpearson.com




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

* Re: Trouble getting archives to load as archives
  2008-07-05  1:32   ` Davin Pearson
@ 2008-07-05  2:23     ` Bernardo Bacic
  2008-07-05  2:57       ` Davin Pearson
  0 siblings, 1 reply; 14+ messages in thread
From: Bernardo Bacic @ 2008-07-05  2:23 UTC (permalink / raw)
  To: Davin Pearson; +Cc: help-gnu-emacs

it was a dark and stormy night when Davin Pearson said, On 07/05/2008 11:32 AM:
> On Jul 5, 9:57 am, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
>>   ("\\.\\(arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\)\\'" .
>> archive-mode)
>>   ("\\.\\(ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\)\\'" .
>> archive-mode)
> 
> Trouble is that this code doesn't work for TAR or GZ files which I am
> trying to get online.
> 

a few things may be worth checking:
* what is the value of auto-mode-alist when you hit C-h v auto-mode-alist
* does the *Messages* buffer (C-h e) show any errors when you open an
   archive file
* are you really opening TAR/GZ files as opposed to tar/gz?





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

* Re: Trouble getting archives to load as archives
  2008-07-05  2:23     ` Bernardo Bacic
@ 2008-07-05  2:57       ` Davin Pearson
  2008-07-05  8:19         ` Peter Dyballa
  0 siblings, 1 reply; 14+ messages in thread
From: Davin Pearson @ 2008-07-05  2:57 UTC (permalink / raw)
  To: bernardo.bacic; +Cc: help-gnu-emacs

2008/7/5 Bernardo Bacic <bernardo.bacic@pobox.com>:
> a few things may be worth checking:
> * what is the value of auto-mode-alist when you hit C-h v auto-mode-alist
> * does the *Messages* buffer (C-h e) show any errors when you open an
>  archive file
> * are you really opening TAR/GZ files as opposed to tar/gz?

Here is the error when I tried to load a tar file:

File mode specification error: (error "Buffer format not recognized")

Here is the error when I tried to load a gz file:

Loading jka-compr...done
uncompressing allegro-1-connect-four-20070702-165627.tar.gz...done
File mode specification error: (error "Buffer format not recognized")

Note that I really mean tar file not TAR file
                                                                and gz
file not GZ file.

Thanks for your help.

-- 
Sincerely and kindest regards, Davin.
Davin Pearson http://www.davinpearson.com




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

* Re: Trouble getting archives to load as archives
  2008-07-05  2:57       ` Davin Pearson
@ 2008-07-05  8:19         ` Peter Dyballa
  2008-07-06  8:21           ` Davin Pearson
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Dyballa @ 2008-07-05  8:19 UTC (permalink / raw)
  To: Davin Pearson; +Cc: help-gnu-emacs


Am 05.07.2008 um 04:57 schrieb Davin Pearson:

> Loading jka-compr...done
> uncompressing allegro-1-connect-four-20070702-165627.tar.gz...done
> File mode specification error: (error "Buffer format not recognized")


How does it work when you invoke GNU Emacs as 'emacs -Q' or 'emacs - 
q' ? With -Q neither the system's nor your own customisation is  
loaded, with -q your's not loaded. In either both or in one case GNU  
Emacs should behave correctly ...

--
Greetings

   Pete

With Capitalism man exploits man. With communism it's the exact  
opposite.






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

* Re: Trouble getting archives to load as archives
  2008-07-05  8:19         ` Peter Dyballa
@ 2008-07-06  8:21           ` Davin Pearson
  2008-07-08  7:00             ` Kevin Rodgers
  0 siblings, 1 reply; 14+ messages in thread
From: Davin Pearson @ 2008-07-06  8:21 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs

2008/7/5 Peter Dyballa <Peter_Dyballa@web.de>:
> How does it work when you invoke GNU Emacs as 'emacs -Q' or 'emacs -q' ?
> With -Q neither the system's nor your own customisation is loaded, with -q
> your's not loaded. In either both or in one case GNU Emacs should behave
> correctly ...

With -q and -Q and the following:

(add-to-list 'auto-mode-alist
'("\\.\\(arc\\|zip\\|tar\\|gz\\|lzh\\|zoo\\)\\'" . archive-mode))

Then loading a *.tar or *.gz file generates the following error messages:

File mode specification error: (error "Buffer format not recognized") [3 times]

Don't worry abou this as I have managed to get cygstart online
whenever you load a file in dired, so that a Winzip window pops up
whenever you load an archive file.

-- 
Sincerely and kindest regards, Davin.
Davin Pearson http://www.davinpearson.com




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

* Re: Trouble getting archives to load as archives
  2008-07-05  1:37   ` Davin Pearson
@ 2008-07-06 10:59     ` Thierry Volpiatto
  0 siblings, 0 replies; 14+ messages in thread
From: Thierry Volpiatto @ 2008-07-06 10:59 UTC (permalink / raw)
  To: Davin Pearson; +Cc: help-gnu-emacs

"Davin Pearson" <davin.pearson@gmail.com> writes:

> 2008/7/4 Thierry Volpiatto <thierry.volpiatto@gmail.com>:
>> an other solution is to use avfs, with that you can open any archives on
>> read/write mode just as any directory in dired.
>> So just install avfs and set fuse in your kernel (and install fuse)
>> I use this code to use it in emacs:
>>
>> ,----[ avfs in dired ]
>> | (defun tv-dired-browse-archive ()
>> |   "This function use avfs and fuse, so be sure
>> | to have these programs and modules installed on your system"
>> |   (interactive)
>> |   (let ((file-at-point (dired-get-filename)))
>> |     (if (or (equal (file-name-extension file-at-point) "gz")
>> |             (equal (file-name-extension file-at-point) "bz2")
>> |             (equal (file-name-extension file-at-point) "zip"))
>> |         (progn
>> |           (when (not (cddr (directory-files "~/.avfs")))
>> |             (shell-command "mountavfs"))
>> |           (find-file (concat "~/.avfs" file-at-point "#")))
>> |       (find-file file-at-point))))
>> | (define-key dired-mode-map (kbd "z") 'tv-dired-browse-archive)
>> `----
>
> Are you sure that it is worth the trouble installing AVS?
I am not sure to understand you.
With avfs you can browse any compressed
archives (like the emacs sources) just like if they were uncompressed
 
http://sourceforge.net/projects/avf

> Have you got AVS installed on your O/S?
Yes you must and you need fuse installed and also enabled in your
kernel.

> Are you using Linux or Windows XP? I am using XP.
I use Gentoo/Linux.
I don't know about XP.
-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




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

* Re: Trouble getting archives to load as archives
  2008-07-06  8:21           ` Davin Pearson
@ 2008-07-08  7:00             ` Kevin Rodgers
  2008-07-08  7:23               ` Peter Dyballa
  2008-07-08 10:52               ` Bernardo Bacic
  0 siblings, 2 replies; 14+ messages in thread
From: Kevin Rodgers @ 2008-07-08  7:00 UTC (permalink / raw)
  To: help-gnu-emacs

Davin Pearson wrote:
> 2008/7/5 Peter Dyballa <Peter_Dyballa@web.de>:
>> How does it work when you invoke GNU Emacs as 'emacs -Q' or 'emacs -q' ?
>> With -Q neither the system's nor your own customisation is loaded, with -q
>> your's not loaded. In either both or in one case GNU Emacs should behave
>> correctly ...
> 
> With -q and -Q and the following:
> 
> (add-to-list 'auto-mode-alist
> '("\\.\\(arc\\|zip\\|tar\\|gz\\|lzh\\|zoo\\)\\'" . archive-mode))
> 
> Then loading a *.tar or *.gz file generates the following error messages:
> 
> File mode specification error: (error "Buffer format not recognized") [3 times]

That's because archive-mode does not support .tar or .gz files.  From
arc-mode.el (Emacs 22.2):

;; ARCHIVE TYPES: Currently only the archives below are handled, but the
;; structure for handling just about anything is in place.
;;
;;                        Arc     Lzh     Zip     Zoo
;;                        --------------------------------
;; View listing           Intern  Intern  Intern  Intern
;; Extract member         Y       Y       Y       Y
;; Save changed member    Y       Y       Y       Y
;; Add new member         N       N       N       N
;; Delete member          Y       Y       Y       Y
;; Rename member          Y       Y       N       N
;; Chmod                  -       Y       Y       -
;; Chown                  -       Y       -       -
;; Chgrp                  -       Y       -       -

...

(defun archive-find-type ()
   (widen)
   (goto-char (point-min))
   ;; The funny [] here make it unlikely that the .elc file will be treated
   ;; as an archive by other software.
   (let (case-fold-search)
     (cond ((looking-at "[P]K\003\004") 'zip)
	  ((looking-at "..-l[hz][0-9ds]-") 'lzh)
	  ((looking-at "....................[\334]\247\304\375") 'zoo)
	  ((and (looking-at "\C-z")	; signature too simple, IMHO
		(string-match "\\.[aA][rR][cC]$"
			      (or buffer-file-name (buffer-name))))
	   'arc)
           ;; This pattern modelled on the BSD/GNU+Linux `file' command.
           ;; Have seen capital "LHA's", and file has lower case "LHa's" 
too.
           ;; Note this regexp is also in archive-exe-p.
           ((looking-at "MZ\\(.\\|\n\\)\\{34\\}LH[aA]'s SFX ") 'lzh-exe)
	  (t (error "Buffer format not recognized")))))


-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: Trouble getting archives to load as archives
  2008-07-08  7:00             ` Kevin Rodgers
@ 2008-07-08  7:23               ` Peter Dyballa
  2008-07-08 10:52               ` Bernardo Bacic
  1 sibling, 0 replies; 14+ messages in thread
From: Peter Dyballa @ 2008-07-08  7:23 UTC (permalink / raw)
  To: Kevin Rodgers; +Cc: emacs list, Davin Pearson


Am 08.07.2008 um 09:00 schrieb Kevin Rodgers:

> That's because archive-mode does not support .tar or .gz files.  From
> arc-mode.el (Emacs 22.2):


I see now! Anyway, tar-mode offers the same functions for compressed  
and uncompressed tape archives, it only does not call its mode  
"archive-mode" ...

--
Greetings

   Pete

Ce qui été compris n'existe plus.    (Paul Eluard)






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

* Re: Trouble getting archives to load as archives
  2008-07-08  7:00             ` Kevin Rodgers
  2008-07-08  7:23               ` Peter Dyballa
@ 2008-07-08 10:52               ` Bernardo Bacic
  2008-07-08 11:24                 ` Peter Dyballa
  1 sibling, 1 reply; 14+ messages in thread
From: Bernardo Bacic @ 2008-07-08 10:52 UTC (permalink / raw)
  To: help-gnu-emacs

it was a dark and stormy night when Kevin Rodgers said, On 07/08/2008 05:00 PM:
> Davin Pearson wrote:
>> 2008/7/5 Peter Dyballa <Peter_Dyballa@web.de>:
>>> How does it work when you invoke GNU Emacs as 'emacs -Q' or 'emacs -q' ?
>>> With -Q neither the system's nor your own customisation is loaded, 
>>> with -q
>>> your's not loaded. In either both or in one case GNU Emacs should behave
>>> correctly ...
>>
>> With -q and -Q and the following:
>>
>> (add-to-list 'auto-mode-alist
>> '("\\.\\(arc\\|zip\\|tar\\|gz\\|lzh\\|zoo\\)\\'" . archive-mode))
>>
>> Then loading a *.tar or *.gz file generates the following error messages:
>>
>> File mode specification error: (error "Buffer format not recognized") 
>> [3 times]
> 
> That's because archive-mode does not support .tar or .gz files.  From
> arc-mode.el (Emacs 22.2):

Emacs 22.1.1 started with -Q option (under GNU/Linux) opens a *.tgz file with 
no problems.
(info "(emacs) Compressed Files")

 From memory, the OP was referring to version 21.*, not sure what the 
situation is there. Perhaps adding tar and gz extensions to auto-mode-alist 
was unnecessary?




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

* Re: Trouble getting archives to load as archives
  2008-07-08 10:52               ` Bernardo Bacic
@ 2008-07-08 11:24                 ` Peter Dyballa
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Dyballa @ 2008-07-08 11:24 UTC (permalink / raw)
  To: bernardo.bacic; +Cc: help-gnu-emacs


Am 08.07.2008 um 12:52 schrieb Bernardo Bacic:

> From memory, the OP was referring to version 21.*, not sure what  
> the situation is there. Perhaps adding tar and gz extensions to  
> auto-mode-alist was unnecessary?

I have also a version of GNU Emacs 21.3.50 (more like 22.x), and  
20.7. In elder Emacsen, I think up to and including 20.x, it was  
necessary to

	(load-library "jka-compr")

Then jka-compr added well-known extensions and also an entry on jka- 
compr-mode (or such) to handle particular file types. And maybe  
telling it about modern compressors/file name endings like tgz, tbz,  
tbz2, tar.bz2 was needed. Tar-mode itself works since at least 18.x.

Therefore my old question what was happening when GNU Emacs was  
launched without any customisation ...

--
Greetings

   Pete

Ce qui été compris n'existe plus.    (Paul Eluard)






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

end of thread, other threads:[~2008-07-08 11:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03 22:59 Trouble getting archives to load as archives Davin Pearson
2008-07-04  5:38 ` Thierry Volpiatto
2008-07-05  1:37   ` Davin Pearson
2008-07-06 10:59     ` Thierry Volpiatto
2008-07-04 21:57 ` Peter Dyballa
     [not found] ` <mailman.14225.1215208751.18990.help-gnu-emacs@gnu.org>
2008-07-05  1:32   ` Davin Pearson
2008-07-05  2:23     ` Bernardo Bacic
2008-07-05  2:57       ` Davin Pearson
2008-07-05  8:19         ` Peter Dyballa
2008-07-06  8:21           ` Davin Pearson
2008-07-08  7:00             ` Kevin Rodgers
2008-07-08  7:23               ` Peter Dyballa
2008-07-08 10:52               ` Bernardo Bacic
2008-07-08 11:24                 ` Peter Dyballa

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.