* netrc.el: Autoload encrypt when encrypt-file-alist is set.
authorTeodor Zlatanov <tzz@lifelogs.com>
Tue, 18 Dec 2007 20:29:33 +0000 (20:29 +0000)
committerTeodor Zlatanov <tzz@lifelogs.com>
Tue, 18 Dec 2007 20:29:33 +0000 (20:29 +0000)
(netrc-parse): Use encrypt-file-alist to determine if
encrypt-find-model or encrypt-insert-file-contents should be used.

* encrypt.el: Clarify documentation.  Load password-cache or
password, whichever one is found first, instead of autoloading.

lisp/ChangeLog
lisp/encrypt.el
lisp/netrc.el

index 40e6af5..016f301 100644 (file)
@@ -1,3 +1,12 @@
+2007-12-19  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * netrc.el: Autoload encrypt when encrypt-file-alist is set.
+       (netrc-parse): Use encrypt-file-alist to determine if
+       encrypt-find-model or encrypt-insert-file-contents should be used.
+
+       * encrypt.el: Clarify documentation.  Load password-cache or
+       password, whichever one is found first, instead of autoloading.
+
 2007-12-17  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus-art.el (gnus-article-browse-html-parts): Add message header and
index 1fb54a2..9225eed 100644 (file)
 ;;; particular aspect.
 
 ;;; Use in Gnus like this:
+;;; (require 'encrypt)
 ;;; (setq
 ;;;   nnimap-authinfo-file "~/.authinfo.enc"
 ;;;   nntp-authinfo-file "~/.authinfo.enc"
 ;;;   smtpmail-auth-credentials "~/.authinfo.enc"
-;;;   ;; using the AES256 cipher, feel free to use your own favorite
+;;;   ;; GnuPG using the AES256 cipher, feel free to use your own favorite
 ;;;   encrypt-file-alist (quote (("~/.authinfo.enc" (gpg "AES256"))))
 ;;;   password-cache-expiry 600)
 
@@ -53,7 +54,9 @@
 
 ;; autoload password
 (eval-and-compile
-  (autoload 'password-read "password"))
+  (if (locate-library "password-cache")
+      (require 'password-cache)
+    (require 'password)))
 
 (defgroup encrypt '((password-cache custom-variable)
                    (password-cache-expiry custom-variable))
index d7de10a..a41ced2 100644 (file)
 ;;; .netrc and .authinfo rc parsing
 ;;;
 
+;; use encrypt if loaded (encrypt-file-alist has to be set as well)
+(eval-and-compile
+  (autoload 'encrypt-find-model "encrypt")
+  (autoload 'encrypt-insert-file-contents "encrypt"))
 (defalias 'netrc-point-at-eol
   (if (fboundp 'point-at-eol)
       'point-at-eol
       (let ((tokens '("machine" "default" "login"
                      "password" "account" "macdef" "force"
                      "port"))
+           (encryption-model (when (bound-and-true-p encrypt-file-alist)
+                               (encrypt-find-model file)))
            alist elem result pair)
-       (insert-file-contents file)
+       (if encryption-model
+           (encrypt-insert-file-contents file encryption-model)
+         (insert-file-contents file))
        (goto-char (point-min))
        ;; Go through the file, line by line.
        (while (not (eobp))