diff options
| author | Glenn Morris | 2012-06-22 00:01:32 -0700 |
|---|---|---|
| committer | Glenn Morris | 2012-06-22 00:01:32 -0700 |
| commit | a4c8dd51c1ca62fbfc4fce54a4e90f6604d073af (patch) | |
| tree | 447e9465640e0d37725144e9054eecd4bda8069c | |
| parent | d251c37c729a3c96ad10c5f6675370d371159534 (diff) | |
| download | emacs-a4c8dd51c1ca62fbfc4fce54a4e90f6604d073af.tar.gz emacs-a4c8dd51c1ca62fbfc4fce54a4e90f6604d073af.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/pcmpl-rpm.el | 36 |
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 @@ | |||
| 1 | 2012-06-22 Glenn Morris <rgm@gnu.org> | 1 | 2012-06-22 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * pcmpl-rpm.el (pcmpl-rpm): New group. | ||
| 4 | (pcmpl-rpm-query-options): New option. | ||
| 5 | (pcmpl-rpm-packages): No need to inline it. | ||
| 6 | Use pcmpl-rpm-query-options. | ||
| 7 | |||
| 3 | * calendar/calendar.el (calendar-in-read-only-buffer): | 8 | * calendar/calendar.el (calendar-in-read-only-buffer): |
| 4 | Avoid some needless mode changes. | 9 | Avoid some needless mode changes. |
| 5 | 10 | ||
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 @@ | |||
| 27 | 27 | ||
| 28 | (require 'pcomplete) | 28 | (require 'pcomplete) |
| 29 | 29 | ||
| 30 | (defgroup pcmpl-rpm nil | ||
| 31 | "Options for rpm completion." | ||
| 32 | :group 'pcomplete | ||
| 33 | :prefix "pcmpl-rpm-") | ||
| 34 | |||
| 35 | ;; rpm -qa can be slow. Adding --nodigest --nosignature is MUCH faster. | ||
| 36 | (defcustom pcmpl-rpm-query-options | ||
| 37 | (let (opts) | ||
| 38 | (with-temp-buffer | ||
| 39 | (when (ignore-errors (call-process "rpm" nil t nil "--help")) | ||
| 40 | (if (search-backward "--nodigest " nil 'move) | ||
| 41 | (setq opts '("--nodigest"))) | ||
| 42 | (goto-char (point-min)) | ||
| 43 | (if (search-forward "--nosignature " nil t) | ||
| 44 | (push "--nosignature" opts)))) | ||
| 45 | opts) | ||
| 46 | "List of extra options to add to an rpm query command." | ||
| 47 | :version "24.2" | ||
| 48 | :type '(repeat string) | ||
| 49 | :group 'pcmpl-rpm) | ||
| 50 | |||
| 30 | ;; Functions: | 51 | ;; Functions: |
| 31 | 52 | ||
| 32 | ;; FIXME rpm -qa can be slow, so: | 53 | ;; TODO |
| 33 | ;; Adding --nodigest --nosignature is MUCH faster. | 54 | ;; This can be slow, so: |
| 34 | ;; (Probably need to test --help for those options though.) | ||
| 35 | ;; Consider caching the result (cf woman). | 55 | ;; Consider caching the result (cf woman). |
| 36 | ;; Consider printing an explanatory message before running -qa. | 56 | ;; Consider printing an explanatory message before running -qa. |
| 37 | ;; | 57 | (defun pcmpl-rpm-packages () |
| 38 | ;; Seems pointless for this to be a defsubst. | 58 | "Return a list of all installed rpm packages." |
| 39 | (defsubst pcmpl-rpm-packages () | 59 | (split-string (apply 'pcomplete-process-result "rpm" |
| 40 | (split-string (pcomplete-process-result "rpm" "-q" "-a"))) | 60 | (append '("-q" "-a") pcmpl-rpm-query-options)))) |
| 41 | 61 | ||
| 62 | ;; Should this use pcmpl-rpm-query-options? | ||
| 63 | ;; I don't think it would speed it up at all (?). | ||
| 42 | (defun pcmpl-rpm-all-query (flag) | 64 | (defun pcmpl-rpm-all-query (flag) |
| 43 | (message "Querying all packages with `%s'..." flag) | 65 | (message "Querying all packages with `%s'..." flag) |
| 44 | (let ((pkgs (pcmpl-rpm-packages)) | 66 | (let ((pkgs (pcmpl-rpm-packages)) |