summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/pcmpl-rpm.el36
2 files changed, 34 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c5be8c263d5..6ac1cc95d4d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
2012-06-22 Glenn Morris <rgm@gnu.org>
+ * pcmpl-rpm.el (pcmpl-rpm): New group.
+ (pcmpl-rpm-query-options): New option.
+ (pcmpl-rpm-packages): No need to inline it.
+ Use pcmpl-rpm-query-options.
+
* calendar/calendar.el (calendar-in-read-only-buffer):
Avoid some needless mode changes.
diff --git a/lisp/pcmpl-rpm.el b/lisp/pcmpl-rpm.el
index f28469d791b..6347666507b 100644
--- a/lisp/pcmpl-rpm.el
+++ b/lisp/pcmpl-rpm.el
@@ -27,18 +27,40 @@
(require 'pcomplete)
+(defgroup pcmpl-rpm nil
+ "Options for rpm completion."
+ :group 'pcomplete
+ :prefix "pcmpl-rpm-")
+
+;; rpm -qa can be slow. Adding --nodigest --nosignature is MUCH faster.
+(defcustom pcmpl-rpm-query-options
+ (let (opts)
+ (with-temp-buffer
+ (when (ignore-errors (call-process "rpm" nil t nil "--help"))
+ (if (search-backward "--nodigest " nil 'move)
+ (setq opts '("--nodigest")))
+ (goto-char (point-min))
+ (if (search-forward "--nosignature " nil t)
+ (push "--nosignature" opts))))
+ opts)
+ "List of extra options to add to an rpm query command."
+ :version "24.2"
+ :type '(repeat string)
+ :group 'pcmpl-rpm)
+
;; Functions:
-;; FIXME rpm -qa can be slow, so:
-;; Adding --nodigest --nosignature is MUCH faster.
-;; (Probably need to test --help for those options though.)
+;; TODO
+;; This can be slow, so:
;; Consider caching the result (cf woman).
;; Consider printing an explanatory message before running -qa.
-;;
-;; Seems pointless for this to be a defsubst.
-(defsubst pcmpl-rpm-packages ()
- (split-string (pcomplete-process-result "rpm" "-q" "-a")))
+(defun pcmpl-rpm-packages ()
+ "Return a list of all installed rpm packages."
+ (split-string (apply 'pcomplete-process-result "rpm"
+ (append '("-q" "-a") pcmpl-rpm-query-options))))
+;; Should this use pcmpl-rpm-query-options?
+;; I don't think it would speed it up at all (?).
(defun pcmpl-rpm-all-query (flag)
(message "Querying all packages with `%s'..." flag)
(let ((pkgs (pcmpl-rpm-packages))