* python-find-imports fails on multi-line import statements
@ 2007-09-07 17:59 Michael Droettboom
2007-09-08 10:05 ` Michael Droettboom
2007-09-08 11:54 ` Dave Love
0 siblings, 2 replies; 3+ messages in thread
From: Michael Droettboom @ 2007-09-07 17:59 UTC (permalink / raw)
To: bug-gnu-emacs; +Cc: fx
Python allows the '\' character to be used to break statements onto
multiple lines.
If I have a group of import statements like
from foo import this, that, other_thing \
and_another_thing
import sys
python-find-imports parses this into
from foo import this, that, other_thing \
import sys
When python-complete-symbol is called and this is passed to complete()
in emacs.py, for instance, it executes this string, which contains a
syntax error, and the autocompletion fails.
I imagine this can be fixed by tinkering with the regular
expressions/filtering in python-find-imports, but I'm not much of an
emacs lisp hacker.
Cheers,
Mike
--
Michael Droettboom
http://www.droettboom.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: python-find-imports fails on multi-line import statements
2007-09-07 17:59 python-find-imports fails on multi-line import statements Michael Droettboom
@ 2007-09-08 10:05 ` Michael Droettboom
2007-09-08 11:54 ` Dave Love
1 sibling, 0 replies; 3+ messages in thread
From: Michael Droettboom @ 2007-09-08 10:05 UTC (permalink / raw)
To: bug-gnu-emacs; +Cc: fx
The emacs version is 22.5.1
On 9/7/07, Michael Droettboom <mike@droettboom.com> wrote:
> Python allows the '\' character to be used to break statements onto
> multiple lines.
>
> If I have a group of import statements like
>
> from foo import this, that, other_thing \
> and_another_thing
> import sys
>
> python-find-imports parses this into
>
> from foo import this, that, other_thing \
> import sys
>
> When python-complete-symbol is called and this is passed to complete()
> in emacs.py, for instance, it executes this string, which contains a
> syntax error, and the autocompletion fails.
>
> I imagine this can be fixed by tinkering with the regular
> expressions/filtering in python-find-imports, but I'm not much of an
> emacs lisp hacker.
>
> Cheers,
> Mike
>
> --
> Michael Droettboom
> http://www.droettboom.com/
>
--
Michael Droettboom
http://www.droettboom.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: python-find-imports fails on multi-line import statements
2007-09-07 17:59 python-find-imports fails on multi-line import statements Michael Droettboom
2007-09-08 10:05 ` Michael Droettboom
@ 2007-09-08 11:54 ` Dave Love
1 sibling, 0 replies; 3+ messages in thread
From: Dave Love @ 2007-09-08 11:54 UTC (permalink / raw)
To: Michael Droettboom; +Cc: bug-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 342 bytes --]
"Michael Droettboom" <mike@droettboom.com> writes:
> I imagine this can be fixed by tinkering with the regular
> expressions/filtering in python-find-imports, but I'm not much of an
> emacs lisp hacker.
Yes, I was sloppy. Thanks. It's fixed in
http://www.loveshack.ukfsn.org/emacs/python-21.el. Perhaps this will
apply to your version:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 678 bytes --]
--- python-21.el 2007/08/30 22:22:45 1.47
+++ python-21.el 2007/09/08 11:44:55 1.48
@@ -1935,9 +1935,13 @@
(goto-char (point-min))
(while (re-search-forward "^import\\>\\|^from\\>" nil t)
(unless (syntax-ppss-context (syntax-ppss))
- (push (buffer-substring (line-beginning-position)
- (line-beginning-position 2))
- lines)))
+ (let ((start (line-beginning-position)))
+ ;; Skip over continued lines.
+ (while (and (eq ?\\ (char-before (line-end-position)))
+ (= 0 (forward-line 1)))
+ t)
+ (push (buffer-substring start (line-beginning-position 2))
+ lines))))
(setq python-imports
(if lines
(apply #'concat
[-- Attachment #3: Type: text/plain, Size: 149 bytes --]
_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-08 11:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-07 17:59 python-find-imports fails on multi-line import statements Michael Droettboom
2007-09-08 10:05 ` Michael Droettboom
2007-09-08 11:54 ` Dave Love
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).