]> git.eshelyaron.com Git - emacs.git/commitdiff
Disregard leading whitespace when forming module completions
authorDan Davison <dandavison7@gmail.com>
Thu, 17 May 2012 03:03:39 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:39 +0000 (00:03 -0300)
This allows an indented import line (e.g. in a function or method
body) to be completed.

lisp/progmodes/python.el

index a10e71dab78dce260e14fd8b918fc534684acda5..59802cca6239e80601a64382561ce694ba43d49a 100644 (file)
@@ -1761,7 +1761,7 @@ completions on the current context."
                          (length python-shell-completion-module-string-code) 0)
                         (string-match
                          (concat "^" python-shell-prompt-regexp) prompt)
-                        (string-match "^\\(from\\|import\\)[ \t]" line))
+                        (string-match "^[ \t]*\\(from\\|import\\)[ \t]" line))
                    'import)
                   ((string-match
                     (concat "^" python-shell-prompt-regexp) prompt)
@@ -1774,7 +1774,9 @@ completions on the current context."
              ('default python-shell-completion-string-code)
              (t nil)))
           (input
-           (if (eq completion-context 'import) line input))
+           (if (eq completion-context 'import)
+               (replace-regexp-in-string "^[ \t]+" "" line)
+             input))
            (completions
             (and completion-code (> (length input) 0)
                  (python-shell-completion--get-completions