mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-09 05:01:02 -08:00
Try to speed up pcomplete's calling of rpm -qa
Ref: http://lists.gnu.org/archive/html/emacs-devel/2012-04/msg00174.html * lisp/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.
This commit is contained in:
parent
d251c37c72
commit
a4c8dd51c1
2 changed files with 34 additions and 7 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue