]> code.delx.au - gnu-emacs/blobdiff - lisp/net/netrc.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / net / netrc.el
index 8c4b0a08f5122151567cc63a41516536d201d4ce..67c8dd43b82489d6d980d42a7b773477148aff2b 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
     'line-end-position))
-;; autoload encrypt
-
-(eval-and-compile
-  (autoload 'encrypt-find-model "encrypt")
-  (autoload 'encrypt-insert-file-contents "encrypt"))
+(eval-when-compile
+  (defvar encrypt-file-alist)
+  ;; This is unnecessary in the compiled version as it is a macro.
+  (if (fboundp 'bound-and-true-p)
+      (defalias 'netrc-bound-and-true-p 'bound-and-true-p)
+    (defmacro netrc-bound-and-true-p (var)
+      "Return the value of symbol VAR if it is bound, else nil."
+      `(and (boundp (quote ,var)) ,var))))
 
 (defgroup netrc nil
  "Netrc configuration."
       (let ((tokens '("machine" "default" "login"
                      "password" "account" "macdef" "force"
                      "port"))
-           (encryption-model (encrypt-find-model file))
+           (encryption-model (when (netrc-bound-and-true-p encrypt-file-alist)
+                               (encrypt-find-model file)))
            alist elem result pair)
-
        (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))
@@ -190,8 +196,7 @@ MODE can be \"login\" or \"password\", suitable for passing to
     (setq type (or type 'tcp))
     (while (and (setq service (pop services))
                (not (and (= number (cadr service))
-                         (eq type (caddr service)))))
-      )
+                         (eq type (car (cddr service)))))))
     (car service)))
 
 (defun netrc-find-service-number (name &optional type)
@@ -200,8 +205,7 @@ MODE can be \"login\" or \"password\", suitable for passing to
     (setq type (or type 'tcp))
     (while (and (setq service (pop services))
                (not (and (string= name (car service))
-                         (eq type (caddr service)))))
-      )
+                         (eq type (car (cddr service)))))))
     (cadr service)))
 
 (provide 'netrc)