emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/jka-cmpr-hook.el


From: Luc Teirlinck
Subject: [Emacs-diffs] Changes to emacs/lisp/jka-cmpr-hook.el
Date: Mon, 27 Feb 2006 01:47:56 +0000

Index: emacs/lisp/jka-cmpr-hook.el
diff -u emacs/lisp/jka-cmpr-hook.el:1.9 emacs/lisp/jka-cmpr-hook.el:1.10
--- emacs/lisp/jka-cmpr-hook.el:1.9     Mon Feb  6 14:33:34 2006
+++ emacs/lisp/jka-cmpr-hook.el Mon Feb 27 01:47:56 2006
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file contains the  code to enable and disable Auto-Compression mode.
+;; This file contains the code to enable and disable Auto-Compression mode.
 ;; It is preloaded.  The guts of this mode are in jka-compr.el, which
 ;; is loaded only when you really try to uncompress something.
 
@@ -113,7 +113,12 @@
 
 Because of the way `call-process' is defined, discarding the stderr output of
 a program adds the overhead of starting a shell each time the program is
-invoked."
+invoked.
+
+If you set this outside Custom while Auto Compression mode is
+already enabled \(as it is by default), you have to call
+`jka-compr-update' after setting it to properly update other
+variables.  Setting this through Custom does that automatically."
   :type '(repeat (vector regexp
                         (choice :tag "Compress Message"
                                 (string :format "%v")
@@ -132,17 +137,35 @@
                         (boolean :tag "Append")
                         (boolean :tag "Strip Extension")
                         (string :tag "Magic Bytes")))
+  :set 'jka-compr-set
   :group 'jka-compr)
 
 (defcustom jka-compr-mode-alist-additions
   (list (cons "\\.tgz\\'" 'tar-mode) (cons "\\.tbz\\'" 'tar-mode))
-  "A list of pairs to add to `auto-mode-alist' when jka-compr is installed."
+  "List of pairs added to `auto-mode-alist' when installing jka-compr.
+Uninstalling jka-compr removes all pairs from `auto-mode-alist' that
+installing added.
+
+If you set this outside Custom while Auto Compression mode is
+already enabled \(as it is by default), you have to call
+`jka-compr-update' after setting it to properly update other
+variables.  Setting this through Custom does that automatically."
   :type '(repeat (cons string symbol))
+  :set 'jka-compr-set
   :group 'jka-compr)
 
 (defcustom jka-compr-load-suffixes '(".gz")
-  "List of suffixes to try when loading files."
+  "List of compression related suffixes to try when loading files.
+Enabling Auto Compression mode appends this list to `load-file-rep-suffixes',
+which see.  Disabling Auto Compression mode removes all suffixes
+from `load-file-rep-suffixes' that enabling added.
+
+If you set this outside Custom while Auto Compression mode is
+already enabled \(as it is by default), you have to call
+`jka-compr-update' after setting it to properly update other
+variables.  Setting this through Custom does that automatically."
   :type '(repeat string)
+  :set 'jka-compr-set
   :group 'jka-compr)
 
 ;; List of all the elements we actually added to file-coding-system-alist.
@@ -150,7 +173,32 @@
 
 (defvar jka-compr-file-name-handler-entry
   nil
-  "The entry in `file-name-handler-alist' used by the jka-compr I/O 
functions.")
+  "`file-name-handler-alist' entry used by jka-compr I/O functions.")
+
+;; Compiler defvars.  These three variables will be defined later with
+;; `defcustom' when everything used in the :set functions is defined.
+(defvar jka-compr-compression-info-list)
+(defvar jka-compr-mode-alist-additions)
+(defvar jka-compr-load-suffixes)
+
+(defvar jka-compr-compression-info-list--internal nil
+  "Stored value of `jka-compr-compression-info-list'.
+If Auto Compression mode is enabled, this is the value of
+`jka-compr-compression-info-list' when `jka-compr-install' was last called.
+Otherwise, it is nil.")
+
+(defvar jka-compr-mode-alist-additions--internal nil
+  "Stored value of `jka-compr-mode-alist-additions'.
+If Auto Compression mode is enabled, this is the value of
+`jka-compr-mode-alist-additions' when `jka-compr-install' was last called.
+Otherwise, it is nil.")
+
+(defvar jka-compr-load-suffixes--internal nil
+  "Stored value of `jka-compr-load-suffixes'.
+If Auto Compression mode is enabled, this is the value of
+`jka-compr-load-suffixes' when `jka-compr-install' was last called.
+Otherwise, it is nil.")
+
 
 (defun jka-compr-build-file-regexp ()
   (mapconcat
@@ -194,6 +242,13 @@
 
   (push jka-compr-file-name-handler-entry file-name-handler-alist)
 
+  (setq jka-compr-compression-info-list--internal
+       jka-compr-compression-info-list
+       jka-compr-mode-alist-additions--internal
+       jka-compr-mode-alist-additions
+       jka-compr-load-suffixes--internal
+       jka-compr-load-suffixes)
+
   (dolist (x jka-compr-compression-info-list)
     ;; Don't do multibyte encoding on the compressed files.
     (let ((elt (cons (jka-compr-info-regexp x)
@@ -216,15 +271,8 @@
        (append auto-mode-alist jka-compr-mode-alist-additions))
 
   ;; Make sure that (load "foo") will find /bla/foo.el.gz.
-  (setq load-suffixes
-       (apply 'append
-              (append (mapcar (lambda (suffix)
-                               (cons suffix
-                                     (mapcar (lambda (ext) (concat suffix ext))
-                                             jka-compr-load-suffixes)))
-                             load-suffixes)
-                       (list jka-compr-load-suffixes)))))
-
+  (setq load-file-rep-suffixes
+       (append load-file-rep-suffixes jka-compr-load-suffixes nil)))
 
 (defun jka-compr-installed-p ()
   "Return non-nil if jka-compr is installed.
@@ -240,10 +288,27 @@
 
     installed))
 
+(defun jka-compr-update ()
+  "Update Auto Compression mode for changes in option values.
+If you change the options `jka-compr-compression-info-list',
+`jka-compr-mode-alist-additions' or `jka-compr-load-suffixes'
+outside Custom, while Auto Compression mode is already enabled
+\(as it is by default), then you have to call this function
+afterward to properly update other variables.  Setting these
+options through Custom does this automatically."
+  (when (jka-compr-installed-p)
+    (jka-compr-uninstall)
+    (jka-compr-install)))
+
+(defun jka-compr-set (variable value)
+  "Internal Custom :set function."
+  (set-default variable value)
+  (jka-compr-update))
+
 (define-minor-mode auto-compression-mode
   "Toggle automatic file compression and uncompression.
 With prefix argument ARG, turn auto compression on if positive, else off.
-Returns the new status of auto compression (non-nil means on)."
+Return the new status of auto compression (non-nil means on)."
   :global t :init-value t :group 'jka-compr :version "22.1"
   (let* ((installed (jka-compr-installed-p))
         (flag auto-compression-mode))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]