From 3d9dc61ef151db514e17e82bb1157f29bd457300 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Mon, 13 Dec 2010 19:59:50 +0100 Subject: [PATCH] (netrc-parse): Cache the netrc contents. --- lisp/ChangeLog | 1 + lisp/netrc.el | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c3399dd6a..7293861fb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,7 @@ * netrc.el (netrc-point-at-eol): Remove the unused netrc-point-at-old and netrc-bound-and-true-p bindings. + (netrc-parse): Cache the netrc contents. * gnus-start.el (gnus-matches-options-n): Fix typo in last change. (gnus-1): Don't create the nndrafts group twice. diff --git a/lisp/netrc.el b/lisp/netrc.el index ed5d4acba..989470bec 100644 --- a/lisp/netrc.el +++ b/lisp/netrc.el @@ -46,12 +46,15 @@ (defvar netrc-services-file "/etc/services" "The name of the services file.") +(defvar netrc-cache nil) + (defun netrc-parse (&optional file) (interactive "fFile to Parse: ") "Parse FILE and return a list of all entries in the file." (unless file (setq file netrc-file)) (if (listp file) + ;; We got already parsed contents; just return it. file (when (file-exists-p file) (with-temp-buffer @@ -59,7 +62,16 @@ "password" "account" "macdef" "force" "port")) alist elem result pair) - (insert-file-contents file) + (if (and netrc-cache + (equal (car netrc-cache) (nth 5 (file-attributes file)))) + ;; Store the contents of the file heavily encrypted in memory. + (insert (base64-decode-string (rot13-string (cdr netrc-cache)))) + (insert-file-contents file) + (when (string-match "\\.gpg\\'" file) + (setq netrc-cache (cons (nth 5 (file-attributes file)) + (rot13-string + (base64-encode-string + (buffer-string))))))) (goto-char (point-min)) ;; Go through the file, line by line. (while (not (eobp)) -- 2.25.1