From: Dan Davison Date: Thu, 17 May 2012 03:03:39 +0000 (-0300) Subject: Disregard leading whitespace when forming module completions X-Git-Tag: emacs-24.2.90~1199^2~498 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=39806de381d46f62c3bef1736a969b86015bf603;p=emacs.git Disregard leading whitespace when forming module completions This allows an indented import line (e.g. in a function or method body) to be completed. --- diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index a10e71dab78..59802cca623 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -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