Function: python--query-import

python--query-import is a byte-compiled function defined in python.el.gz.

Signature

(python--query-import NAME SOURCE PROMPT)

Documentation

Read a Python import statement defining NAME.

A list of candidates is produced by python--list-imports(var)/python--list-imports(fun) using the NAME and SOURCE arguments. An interactive query, using the PROMPT string, is made unless there is a single candidate.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python--query-import (name source prompt)
  "Read a Python import statement defining NAME.
A list of candidates is produced by `python--list-imports' using
the NAME and SOURCE arguments.  An interactive query, using the
PROMPT string, is made unless there is a single candidate."
  (let* ((cands (python--list-imports name source))
         ;; Don't use DEF argument of `completing-read', so it is able
         ;; to return the empty string.
         (minibuffer-default-add-function
          (lambda ()
            (setq minibuffer-default (with-minibuffer-selected-window
                                       (thing-at-point 'symbol)))))
         (statement (cond ((and name (length= cands 1))
                           (car cands))
                          (prompt
                           (completing-read prompt
                                            (or cands python-import-history)
                                            nil nil nil
                                            'python-import-history)))))
    (unless (string-empty-p statement)
      statement)))