aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-06-22 00:38:26 -0700
committerGlenn Morris2012-06-22 00:38:26 -0700
commit575db3f1a8c6978df9d69f49dedd1bff15c73a9d (patch)
treec7656593664eb1dc1065065ccfee84e663deac4c
parentc5695d1d098bc4f275cfe4b4492a70779a06de02 (diff)
downloademacs-575db3f1a8c6978df9d69f49dedd1bff15c73a9d.tar.gz
emacs-575db3f1a8c6978df9d69f49dedd1bff15c73a9d.zip
Further speed up rpm completion, by caching the installed packages
* lisp/pcmpl-rpm.el (pcmpl-rpm-cache): New option. (pcmpl-rpm-cache-stamp-file): New constant. (pcmpl-rpm-cache-time, pcmpl-rpm-packages): New variables. (pcmpl-rpm-packages): Optionally cache list of packages.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/pcmpl-rpm.el29
2 files changed, 30 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1119a52c451..50950a25b5d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -14,6 +14,11 @@
14 14
152012-06-22 Glenn Morris <rgm@gnu.org> 152012-06-22 Glenn Morris <rgm@gnu.org>
16 16
17 * pcmpl-rpm.el (pcmpl-rpm-cache): New option.
18 (pcmpl-rpm-cache-stamp-file): New constant.
19 (pcmpl-rpm-cache-time, pcmpl-rpm-packages): New variables.
20 (pcmpl-rpm-packages): Optionally cache list of packages.
21
17 * pcmpl-rpm.el (pcmpl-rpm): New group. 22 * pcmpl-rpm.el (pcmpl-rpm): New group.
18 (pcmpl-rpm-query-options): New option. 23 (pcmpl-rpm-query-options): New option.
19 (pcmpl-rpm-packages): No need to inline it. 24 (pcmpl-rpm-packages): No need to inline it.
diff --git a/lisp/pcmpl-rpm.el b/lisp/pcmpl-rpm.el
index 6347666507b..12fce363804 100644
--- a/lisp/pcmpl-rpm.el
+++ b/lisp/pcmpl-rpm.el
@@ -48,16 +48,37 @@
48 :type '(repeat string) 48 :type '(repeat string)
49 :group 'pcmpl-rpm) 49 :group 'pcmpl-rpm)
50 50
51(defcustom pcmpl-rpm-cache t
52 "Whether to cache the list of installed packages."
53 :version "24.2"
54 :type 'boolean
55 :group 'pcmpl-rpm)
56
57(defconst pcmpl-rpm-cache-stamp-file "/var/lib/rpm/Packages"
58 "File used to check that the list of installed packages is up-to-date.")
59
60(defvar pcmpl-rpm-cache-time nil
61 "Time at which the list of installed packages was updated.")
62
63(defvar pcmpl-rpm-packages nil
64 "List of installed packages.")
65
51;; Functions: 66;; Functions:
52 67
53;; TODO
54;; This can be slow, so: 68;; This can be slow, so:
55;; Consider caching the result (cf woman).
56;; Consider printing an explanatory message before running -qa. 69;; Consider printing an explanatory message before running -qa.
57(defun pcmpl-rpm-packages () 70(defun pcmpl-rpm-packages ()
58 "Return a list of all installed rpm packages." 71 "Return a list of all installed rpm packages."
59 (split-string (apply 'pcomplete-process-result "rpm" 72 (if (and pcmpl-rpm-cache
60 (append '("-q" "-a") pcmpl-rpm-query-options)))) 73 pcmpl-rpm-cache-time
74 (let ((mtime (nth 5 (file-attributes pcmpl-rpm-cache-stamp-file))))
75 (and mtime (not (time-less-p pcmpl-rpm-cache-time mtime)))))
76 pcmpl-rpm-packages
77 (setq pcmpl-rpm-cache-time (current-time)
78 pcmpl-rpm-packages
79 (split-string (apply 'pcomplete-process-result "rpm"
80 (append '("-q" "-a")
81 pcmpl-rpm-query-options))))))
61 82
62;; Should this use pcmpl-rpm-query-options? 83;; Should this use pcmpl-rpm-query-options?
63;; I don't think it would speed it up at all (?). 84;; I don't think it would speed it up at all (?).