commit 9a765844a093488715a3249ec5b91361d506a8bb Author: Russell Sim Date: Wed Jul 11 12:06:24 2012 +1000 Enhanced py-find-imports to handle multiline imports. diff --git a/python-mode.el b/python-mode.el index 6795843..81ecff8 100644 --- a/python-mode.el +++ b/python-mode.el @@ -8869,11 +8869,19 @@ Useful for newly defined symbol, not known to python yet. " (save-excursion (goto-char (point-min)) (while (re-search-forward - "^import *[A-Za-z_][A-Za-z_0-9].*\\|^from +[A-Za-z_][A-Za-z_0-9]+ +import .*" nil t) - (setq imports - (concat - imports - (buffer-substring-no-properties (match-beginning 0) (match-end 0)) ";")))) + "^import *[A-Za-z_][A-Za-z_0-9].*\\|^from +[A-Za-z_][A-Za-z_0-9.]+ +import .*" nil t) + + (let ((start-point (point))) + (end-of-line) + (while (equal (char-before) (string-to-char "\\")) + (next-line) + (end-of-line)) + (setq imports + (concat + imports + (replace-regexp-in-string + "[\\]\r?\n?\s*" "" + (buffer-substring-no-properties (match-beginning 0) (point))) ";"))))) (when (and py-verbose-p (interactive-p)) (message "%s" imports)) imports))