From 39806de381d46f62c3bef1736a969b86015bf603 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 17 May 2012 00:03:39 -0300 Subject: [PATCH] Disregard leading whitespace when forming module completions This allows an indented import line (e.g. in a function or method body) to be completed. --- lisp/progmodes/python.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 -- 2.11.4.GIT