Article View: gnu.emacs.bug
Article #99401bug in uncompress.el
From: Jamie Zawinski
Date: Thu, 20 Sep 1990 06:32
Date: Thu, 20 Sep 1990 06:32
38 lines
2002 bytes
2002 bytes
Uncompress dies if the .Z file is read-only - the buffer is made read-only
too, and it can't modify it. The fix is obvious, bind buffer-read-only to
nil while uncompressing. It's a short file, so here's the whole thing:
;;; -*- Mode:Emacs-Lisp -*-
(defun uncompress-while-visiting ()
"Temporary \"major mode\" used for .Z files, to uncompress the contents.
It then selects a major mode from the uncompressed file name and contents."
(if (and (not (null buffer-file-name))
(string-match "\\.Z$" buffer-file-name))
(set-visited-file-name
(substring buffer-file-name 0 (match-beginning 0))))
(message "Uncompressing...")
(let ((buffer-read-only nil))
(shell-command-on-region (point-min) (point-max) "uncompress" t)
(message "Uncompressing...done")
(set-buffer-modified-p nil))
(normal-mode))
(setq auto-mode-alist
(cons '("\\.Z$" . uncompress-while-visiting) auto-mode-alist))
(defun find-compressed-version ()
"Hook to read and uncompress the compressed version of a file."
;; Just pretend we had visited the compressed file,
;; and uncompress-while-visiting will do the rest.
(if (file-exists-p (concat buffer-file-name ".Z"))
(progn
(setq buffer-file-name (concat buffer-file-name ".Z"))
(insert-file-contents buffer-file-name t)
(goto-char (point-min))
(setq error nil)
t)))
(setq find-file-not-found-hooks
(cons 'find-compressed-version find-file-not-found-hooks))
Technical Details
Message-ID:
<JWZ.90Sep19233253@kolyma.lucid.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!neon!lucid.com!jwzShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,9b3b22396af5ef6c,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-09-20 18:55:05 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!neon!lucid.com!jwz From: jwz@lucid.com (Jamie Zawinski) Newsgroups: gnu.emacs.bug Subject: bug in uncompress.el Message-ID: <JWZ.90Sep19233253@kolyma.lucid.com> Date: 20 Sep 90 06:32:53 GMT Sender: jwz@lucid.com Organization: Lucid, Inc., Menlo Park, CA Lines: 38 Posted: Thu Sep 20 07:32:53 1990