I wrote:
>
> Unless I've botched that handler...

Ah, which was indeed the case ...


(defun apt-utils-show-package (&optional new-session)
  "Show information for a Debian package.
A selection of known packages is presented.  See `apt-utils-mode'
for more detailed help.  If NEW-SESSION is non-nil, generate a
new `apt-utils-mode' buffer."
  (interactive "P")
  (let ((package (apt-utils-choose-package)))
    (when (> (length package) 0)
      (apt-utils-show-package-1 package t new-session))))

(defun apt-utils-choose-package ()
  "Choose a Debian package name."
  (let ((package
         (and (eq major-mode 'apt-utils-mode)
              (cadr (member 'apt-package
                            (text-properties-at (point)))))))
    (when (not (stringp package))
      (setq package nil))
    (completing-read (if package
                         (format "Choose Debian package (%s): " package)
                       "Choose Debian package: ")
                     'apt-utils-choose-package-completion
                     nil t package)))

;; emacs 22 has `dynamic-completion-table' to help construct a function like
;; this, but emacs 21 (and xemacs 21) doesn't
(defun apt-utils-choose-package-completion (str pred all)
  "Apt package name completion handler, for `completing-read'."
  (let ((enable-recursive-minibuffers t))
    (apt-utils-check-package-lists))
  (let ((collection (cond
                     (apt-utils-completing-read-hashtable-p
                      apt-utils-package-list)
                     (t
                      (apt-utils-build-completion-table
                       apt-utils-package-list)))))
    (cond ((null all)
           (try-completion str collection pred))
          ((eq all t)
           (all-completions str collection pred))
          ((eq all 'lambda)
           (test-completion str collection pred)))))



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to