Path: utzoo!attcan!uunet!kddlab!ccut!titcca!kogwy!koccsun!koscvax!mad From: mad@cabbage.keio.JUNET (MAEDA Atusi) Newsgroups: comp.emacs Subject: Re: Automatically uncompress files when finding them Message-ID: Date: 9 Nov 88 09:07:00 GMT References: <42453@yale-celray.yale.UUCP> Sender: root@kogwy.keio.JUNET Reply-To: mad@nlab.keio.junet Organization: Faculty of Sci. and Tech., Keio Univ., Yokohama, Japan. Lines: 42 In-reply-to: spolsky-joel@CS.Yale.EDU's message of 8 Nov 88 07:09:09 GMT From: spolsky-joel@CS.Yale.EDU (Joel Spolsky) Newsgroups: comp.emacs Date: 8 Nov 88 07:09:09 GMT Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 This is a little function that replaces find-file. Thanks. Yes, I *really* replaced find-file with it. I added the following in my .emacs file. Changes from oridinal code are: 1) Expands file name. So it now works on files in other directory. 2) Replaces the definition of find-file-noselect. Many functions such as dired-find-file or rmail-input are automatically improved. (But this may be dangerous...) Similar trick I am using is delete-file which does not delete file but moves it to `trash' directory and flush later. (fset 'old-find-file-noselect (symbol-function 'find-file-noselect)) (defun find-file-noselect (filename) "Find a file. If it is compressed, uncompress it first. Assumes that any file ending in .Z is compressed. The argument should include a .Z to uncompress a file. See old-find-file-noselect for details." (interactive "FFind file: ") (if (equal (substring filename -2) ".Z") (progn (let* ((buffer-read-only nil) ; code stolen from dired.el (from-file (expand-file-name filename)) (to-file (substring from-file 0 -2))) (message "Uncompressing %s..." from-file) (call-process "uncompress" nil nil nil from-file) (message "Uncompressing %s... done" from-file) (old-find-file-noselect to-file))) (old-find-file-noselect filename))) ;;; MAEDA Atusi (In Japan we write our family names first.) ;;; $@A0EDFX;J(J (My name in japanese characters.) ;;; mad@nlab.keio.junet :JUNET ;;; mad%nlab.keio.junet@relay.cs.net :CSNET