comparison lisp/jka-compr.el @ 32262:44264092481b

(auto-compression-mode): Move to the end of the file, because `define-minor-mode' actually calls the mode-function if the associated variable is non-nil, which requires that all needed functions be already defined. (with-auto-compression-mode): Add autoload cookie.
author Miles Bader <miles@gnu.org>
date Sun, 08 Oct 2000 02:57:01 +0000
parents 8325ae2bc1e4
children ffc41362f67e
comparison
equal deleted inserted replaced
32261:c354d0540694 32262:44264092481b
753 (and (eq inhibit-file-name-operation operation) 753 (and (eq inhibit-file-name-operation operation)
754 inhibit-file-name-handlers))) 754 inhibit-file-name-handlers)))
755 (inhibit-file-name-operation operation)) 755 (inhibit-file-name-operation operation))
756 (apply operation args))) 756 (apply operation args)))
757 757
758 ;;;###autoload
759 (define-minor-mode auto-compression-mode
760 "Toggle automatic file compression and uncompression.
761 With prefix argument ARG, turn auto compression on if positive, else off.
762 Returns the new status of auto compression (non-nil means on)."
763 nil nil nil :global t :group 'jka-compr
764 (let* ((installed (jka-compr-installed-p))
765 (flag auto-compression-mode))
766 (cond
767 ((and flag installed) t) ; already installed
768 ((and (not flag) (not installed)) nil) ; already not installed
769 (flag (jka-compr-install))
770 (t (jka-compr-uninstall)))))
771
772
773 (defmacro with-auto-compression-mode (&rest body)
774 "Evalutes BODY with automatic file compression and uncompression enabled."
775 (let ((already-installed (make-symbol "already-installed")))
776 `(let ((,already-installed (jka-compr-installed-p)))
777 (unwind-protect
778 (progn
779 (unless ,already-installed
780 (jka-compr-install))
781 ,@body)
782 (unless ,already-installed
783 (jka-compr-uninstall))))))
784 (put 'with-auto-compression-mode 'lisp-indent-function 0)
785
786 758
787 (defun jka-compr-build-file-regexp () 759 (defun jka-compr-build-file-regexp ()
788 (mapconcat 760 (mapconcat
789 'jka-compr-info-regexp 761 'jka-compr-info-regexp
790 jka-compr-compression-info-list 762 jka-compr-compression-info-list
899 (setq fnha (cdr fnha))) 871 (setq fnha (cdr fnha)))
900 872
901 installed)) 873 installed))
902 874
903 875
876 ;;;###autoload
877 (define-minor-mode auto-compression-mode
878 "Toggle automatic file compression and uncompression.
879 With prefix argument ARG, turn auto compression on if positive, else off.
880 Returns the new status of auto compression (non-nil means on)."
881 nil nil nil :global t :group 'jka-compr
882 (let* ((installed (jka-compr-installed-p))
883 (flag auto-compression-mode))
884 (cond
885 ((and flag installed) t) ; already installed
886 ((and (not flag) (not installed)) nil) ; already not installed
887 (flag (jka-compr-install))
888 (t (jka-compr-uninstall)))))
889
890
891 ;;;###autoload
892 (defmacro with-auto-compression-mode (&rest body)
893 "Evalutes BODY with automatic file compression and uncompression enabled."
894 (let ((already-installed (make-symbol "already-installed")))
895 `(let ((,already-installed (jka-compr-installed-p)))
896 (unwind-protect
897 (progn
898 (unless ,already-installed
899 (jka-compr-install))
900 ,@body)
901 (unless ,already-installed
902 (jka-compr-uninstall))))))
903 (put 'with-auto-compression-mode 'lisp-indent-function 0)
904
905
904 ;;; Add the file I/O hook if it does not already exist. 906 ;;; Add the file I/O hook if it does not already exist.
905 ;;; Make sure that jka-compr-file-name-handler-entry is eq to the 907 ;;; Make sure that jka-compr-file-name-handler-entry is eq to the
906 ;;; entry for jka-compr in file-name-handler-alist. 908 ;;; entry for jka-compr in file-name-handler-alist.
907 (and (jka-compr-installed-p) 909 (and (jka-compr-installed-p)
908 (jka-compr-uninstall)) 910 (jka-compr-uninstall))