Trouble getting archives to load as archives
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
Trouble getting archives to load as archives         


Author: Davin Pearson
Date: Jul 3, 2008 15:59

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?
11 Comments
Re: Trouble getting archives to load as archives         


Author: Thierry Volpiatto
Date: Jul 3, 2008 22:38

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)
> ...
Show full article (1.73Kb)
no comments
Re: Trouble getting archives to load as archives         


Author: Peter Dyballa
Date: Jul 4, 2008 14:57

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:
Show full article (1.07Kb)
no comments
Re: Trouble getting archives to load as archives         


Author: Davin Pearson
Date: Jul 4, 2008 18:32

On Jul 5, 9:57 am, Peter Dyballa 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.
no comments
Re: Trouble getting archives to load as archives         


Author: Davin Pearson
Date: Jul 4, 2008 18:37

2008/7/4 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)))) ...
Show full article (1.28Kb)
no comments
Re: Trouble getting archives to load as archives         


Author: Bernardo Bacic
Date: Jul 4, 2008 19:23

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 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?
no comments
Re: Trouble getting archives to load as archives         


Author: Davin Pearson
Date: Jul 4, 2008 19:57

2008/7/5 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
no comments
Re: Trouble getting archives to load as archives         


Author: Peter Dyballa
Date: Jul 5, 2008 01:19

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.
no comments
Re: Trouble getting archives to load as archives         


Author: Davin Pearson
Date: Jul 6, 2008 01:21

2008/7/5 Peter Dyballa :
> 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
no comments
Re: Trouble getting archives to load as archives         


Author: Thierry Volpiatto
Date: Jul 6, 2008 03:59

"Davin Pearson" gmail.com> writes:
> 2008/7/4 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...
Show full article (1.64Kb)
no comments
1 2