From kentborg at borg.org Thu Dec 10 16:49:33 2009 From: kentborg at borg.org (Kent Borg) Date: Thu, 10 Dec 2009 10:49:33 -0500 Subject: [Python-mode] Problem with Multi-Line Comments Message-ID: <4B21188D.3030603@borg.org> Hello, I recently started playing with using docstrings more fully and discovered a problem. I can't use apostrophes in multi-line comments without confusing python-mode. For example: > def my_sqrt(x): > '''Computes squareroot. > > Note: This function doesn't know about imaginary numbers, to it > can't handle negative parameters. > ''' It gets all confused by the single quotes. Am I misunderstanding something? Thanks, -kb From skip at pobox.com Fri Dec 11 14:50:02 2009 From: skip at pobox.com (skip at pobox.com) Date: Fri, 11 Dec 2009 07:50:02 -0600 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B21188D.3030603@borg.org> References: <4B21188D.3030603@borg.org> Message-ID: <19234.19978.137603.429130@montanaro.dyndns.org> Kent> Am I misunderstanding something? Perhaps. There is definitely a deficiency in the Emacs syntax table stuff, at least the way python-mode uses it. I believe the other Python mode (the one delivered with recent versions of GNU Emacs) might handle triple-quoted strings better. In many cases you can avoid the problem by using """...""" to surround strings containing apostrophes and '''...''' to surround strings containing quotation marks. The only problem you encounter there is the situation where your doc strings contain both quotation marks and apostrophes. Skip From barry at python.org Fri Dec 11 15:35:22 2009 From: barry at python.org (Barry Warsaw) Date: Fri, 11 Dec 2009 09:35:22 -0500 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <19234.19978.137603.429130@montanaro.dyndns.org> References: <4B21188D.3030603@borg.org> <19234.19978.137603.429130@montanaro.dyndns.org> Message-ID: <6F51488C-86B5-415F-97A7-4851FAD48D5B@python.org> On Dec 11, 2009, at 8:50 AM, skip at pobox.com wrote: > > Kent> Am I misunderstanding something? > > Perhaps. There is definitely a deficiency in the Emacs syntax table stuff, > at least the way python-mode uses it. I believe the other Python mode (the > one delivered with recent versions of GNU Emacs) might handle triple-quoted > strings better. I think python.el uses regular expressions instead of the syntax table. I also thought there were patches to python-mode.el to make it work more closely like python.el. > In many cases you can avoid the problem by using """...""" to surround > strings containing apostrophes and '''...''' to surround strings containing > quotation marks. The only problem you encounter there is the situation > where your doc strings contain both quotation marks and apostrophes. Generally, if the quotes are balanced the worse that can happen is that you'll get a little run of text in a different color. If they're not balanced though, it will mess up Emacs's syntax table logic and you'll need a little "turd" to help line things up again: def foo(): '''Some people don't like this.''' # ' <- Emacs turd It would be nice to fix this. -Barry From andreas.roehler at online.de Fri Dec 11 09:30:17 2009 From: andreas.roehler at online.de (Andreas Roehler) Date: Fri, 11 Dec 2009 09:30:17 +0100 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B21188D.3030603@borg.org> References: <4B21188D.3030603@borg.org> Message-ID: <4B220319.8060700@online.de> Kent Borg wrote: > Hello, > > I recently started playing with using docstrings more fully and > discovered a problem. I can't use apostrophes in multi-line comments > without confusing python-mode. > > For example: > >> def my_sqrt(x): >> '''Computes squareroot. >> >> Note: This function doesn't know about imaginary numbers, to it >> can't handle negative parameters. >> ''' > > It gets all confused by the single quotes. > > Am I misunderstanding something? > > > Thanks, > > -kb Hi, sounds like a well known bug of python-mode.el. Can reproduce it with emacs -Q. Unfortunately not with my common environment, telling me python-mode.el version 351 is in use. See screenshot attached. Strange. BTW which system/version/emacs you are using? Andreas -------------- next part -------------- A non-text attachment was scrubbed... Name: tqs.png Type: image/png Size: 115142 bytes Desc: not available URL: From kentborg at borg.org Fri Dec 11 15:15:05 2009 From: kentborg at borg.org (Kent Borg) Date: Fri, 11 Dec 2009 09:15:05 -0500 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B220319.8060700@online.de> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> Message-ID: <4B2253E9.5010506@borg.org> Andreas Roehler wrote: > BTW which system/version/emacs you are using? kentborg at bottom:~$ emacs --version GNU Emacs 22.2.1 Copyright (C) 2008 Free Software Foundation, Inc. GNU Emacs comes with ABSOLUTELY NO WARRANTY. You may redistribute copies of Emacs under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING. kentborg at bottom:~$ uname -a Linux bottom 2.6.28-17-generic #58-Ubuntu SMP Tue Dec 1 18:57:07 UTC 2009 i686 GNU/Linux kentborg at bottom:~$ cat /etc/debian_version 5.0 kentborg at bottom:~$ cat /etc/issue Ubuntu 9.04 \n \l I am running Gnome under GDM, but "emacs -nw" acts the same way. I notice that when typing that while typing the quote marks, the highlighting seems to be simply counting open-close-open-close, etc. (Clever that three quotes is an odd number so it looks to naive syntax highlighting a bit like a single quote.) Does your emacs update highlighting when you type one quote? Does it update it again after a second? What does it do after a third? And, what does it do on the close set? Oh, one more thing: I moved my .emacs aside to make sure it isn't the problem...and it seems it is not. Thanks, -kb From kentborg at borg.org Fri Dec 11 15:25:48 2009 From: kentborg at borg.org (Kent Borg) Date: Fri, 11 Dec 2009 09:25:48 -0500 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B220319.8060700@online.de> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> Message-ID: <4B22566C.8060106@borg.org> Andreas Roehler wrote: > python-mode.el version 351 is in use. I am not using that version. I dug around and downloaded 351. Internally mine is versioned: "5.1.0", 351 says "5.1.0+". kentborg at bottom:~$ diff /usr/share/emacs/site-lisp/python-mode/python-mode.el /home/kentborg/sw_downloads/python-mode.el 12c12 < (defconst py-version "5.1.0" --- > (defconst py-version "5.1.0+" 2406c2406,2407 < (indent-rigidly start end count))) --- > (let (deactivate-mark) > (indent-rigidly start end count)))) 2419c2420 < (m (mark)) --- > (m (condition-case nil (mark) (mark-inactive nil))) 2447c2448 < (m (mark)) --- > (m (condition-case nil (mark) (mark-inactive nil))) Dropping the new one in place doesn't fix it, but I think I need to compile something... Thanks, -kb, the Kent who is heading off to ask Google again. From kentborg at borg.org Fri Dec 11 15:41:51 2009 From: kentborg at borg.org (Kent Borg) Date: Fri, 11 Dec 2009 09:41:51 -0500 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B22566C.8060106@borg.org> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> <4B22566C.8060106@borg.org> Message-ID: <4B225A2F.8050202@borg.org> Kent Borg wrote: > Dropping the new one in place doesn't fix it, but I think I need to > compile something... Follow up on my last e-mail... OK, I think I compiled it: kentborg at bottom:~$ ls -l /usr/share/emacs/site-lisp/python-mode/python-mode.elc -rw-r--r-- 1 root root 115028 2009-12-11 09:38 /usr/share/emacs/site-lisp/python-mode/python-mode.elc New launch of emacs -nw still gets confused. Thanks for everyone's patience, -kb From barry at python.org Fri Dec 11 15:43:22 2009 From: barry at python.org (Barry Warsaw) Date: Fri, 11 Dec 2009 09:43:22 -0500 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B22566C.8060106@borg.org> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> <4B22566C.8060106@borg.org> Message-ID: On Dec 11, 2009, at 9:25 AM, Kent Borg wrote: > Dropping the new one in place doesn't fix it, but I think I need to > compile something... FWIW, I run python-mode.el right out of a bzr checkout. I never byte compile my personal elisp files any more. :) -Barry From andreas.roehler at online.de Fri Dec 11 19:13:55 2009 From: andreas.roehler at online.de (Andreas Roehler) Date: Fri, 11 Dec 2009 19:13:55 +0100 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B2253E9.5010506@borg.org> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> <4B2253E9.5010506@borg.org> Message-ID: <4B228BE3.1030804@online.de> Kent Borg wrote: > Andreas Roehler wrote: >> BTW which system/version/emacs you are using? > > kentborg at bottom:~$ emacs --version > GNU Emacs 22.2.1 > Copyright (C) 2008 Free Software Foundation, Inc. > GNU Emacs comes with ABSOLUTELY NO WARRANTY. > You may redistribute copies of Emacs > under the terms of the GNU General Public License. > For more information about these matters, see the file named COPYING. > kentborg at bottom:~$ uname -a > Linux bottom 2.6.28-17-generic #58-Ubuntu SMP Tue Dec 1 18:57:07 UTC > 2009 i686 GNU/Linux > kentborg at bottom:~$ cat /etc/debian_version > 5.0 > kentborg at bottom:~$ cat /etc/issue > Ubuntu 9.04 \n \l > > > > I am running Gnome under GDM, but "emacs -nw" acts the same way. > > I notice that when typing that while typing the quote marks, the > highlighting seems to be simply counting open-close-open-close, etc. > (Clever that three quotes is an odd number so it looks to naive syntax > highlighting a bit like a single quote.) > > Does your emacs update highlighting when you type one quote? Yes Does it > update it again after a second? It does it immediatly. What does it do after a third? And, > what does it do on the close set? > > Oh, one more thing: I moved my .emacs aside no need for that, emacs -q or emacs -Q is the right thing then to make sure it isn't the > problem...and it seems it is not. > When started emacs -q you should not encounter that problem - maybe others... Already tried to tackle the issue. Works with GNU Emacs for me, not with XEmacs until now. Introduced some stuff from python.el - defconst python-font-lock-syntactic-keywords etc. Patch attached - not polished yet, but works here some weeks now. Andreas -------------- next part -------------- A non-text attachment was scrubbed... Name: tqs-all-python-mode.patch Type: text/x-patch Size: 9671 bytes Desc: not available URL: From barry at python.org Fri Dec 11 19:31:19 2009 From: barry at python.org (Barry Warsaw) Date: Fri, 11 Dec 2009 13:31:19 -0500 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B228BE3.1030804@online.de> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> <4B2253E9.5010506@borg.org> <4B228BE3.1030804@online.de> Message-ID: On Dec 11, 2009, at 1:13 PM, Andreas Roehler wrote: > Already tried to tackle the issue. Works with GNU Emacs for me, not with XEmacs until now. > Introduced some stuff from python.el - defconst python-font-lock-syntactic-keywords etc. > > Patch attached - not polished yet, but works here some weeks now. Why not push a branch to Launchpad so we can more easily play with it and diff it against trunk? :) -Barry From kentborg at borg.org Fri Dec 11 20:22:04 2009 From: kentborg at borg.org (Kent Borg) Date: Fri, 11 Dec 2009 14:22:04 -0500 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B228BE3.1030804@online.de> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> <4B2253E9.5010506@borg.org> <4B228BE3.1030804@online.de> Message-ID: <4B229BDC.5070001@borg.org> Andreas Roehler wrote: > no need for that, emacs -q or emacs -Q is the right thing then > "emacs -q" does not work, "emacs -Q" does work. (The toggling of highlighting while opening and closing a multi-line comment is like before, but inside a correct multi-line comment, a new ' is happily ignored.) > Patch attached - not polished yet, but works here some weeks now. > Copied it to my /usr/share/emacs/site-lisp/python-mode Tried: # patch python-mode.el tqs-all-python-mode.patch It seemed to work. To check: # diff python-mode.el python-mode.el-351 ...seems to look like the patch file. New emacs doesn't work better, but do I need to open the new python-mode.el and meta-X byte-compile-file or something? python-mode.elc has a new time stamp, does that mean I did it correctly? Thanks, -kb, the Kent who has never gotten into emacs internals and doesn't know the difference between a -q and -Q launch. From andreas.roehler at online.de Sat Dec 12 08:55:12 2009 From: andreas.roehler at online.de (Andreas Roehler) Date: Sat, 12 Dec 2009 08:55:12 +0100 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: <4B229BDC.5070001@borg.org> References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> <4B2253E9.5010506@borg.org> <4B228BE3.1030804@online.de> <4B229BDC.5070001@borg.org> Message-ID: <4B234C60.1080009@online.de> Kent Borg wrote: > Andreas Roehler wrote: >> no need for that, emacs -q or emacs -Q is the right thing then >> > > "emacs -q" does not work, "emacs -Q" does work. (The toggling of > highlighting while opening and closing a multi-line comment is like > before, seems normal, seems the way it proceeds but inside a correct multi-line comment, a new ' is happily > ignored.) reads like ok now. > >> Patch attached - not polished yet, but works here some weeks now. >> > > Copied it to my /usr/share/emacs/site-lisp/python-mode > > Tried: > > # patch python-mode.el tqs-all-python-mode.patch > > It seemed to work. To check: > > # diff python-mode.el python-mode.el-351 > > ...seems to look like the patch file. > > New emacs doesn't work better, but do I need to open the new > python-mode.el and meta-X byte-compile-file or something? Just make sure it's loaded. For example put (load "PATH-TO-NEW-python-mode.el") into your .emacs Comment out old python-mode loads if any. BTW byte-compile is very seldom needed, only if speed matters. Usually you'll not remark a difference. The only common use for me while playing with single files - compiling displays possible errors. > python-mode.elc has a new time stamp, does that mean I did it correctly? > > > Thanks, > > -kb, the Kent who has never gotten into emacs internals and doesn't know > the difference between a -q and -Q launch. > After reading "An Introduction to Programming in Emacs Lisp" you'll enjoy Emacs much more probably: M-x info RET m emacs lisp TAB > From sontek at gmail.com Fri Dec 11 16:19:59 2009 From: sontek at gmail.com (John M. Anderson) Date: Fri, 11 Dec 2009 09:19:59 -0600 Subject: [Python-mode] Code Completion and PyDoc integration Message-ID: <6938f5390912110719n508c7fdbwae1d8de49e42395d@mail.gmail.com> I've recently grown an interest in Python with Emacs and I've been having a hard time getting a decent configuration setup. Currently I'm using the built in python.el inside emacs23 but I haven't really found any compelling reason to use either mode over the other, except everyone says python-mode.el doesn't handle triple quote doc strings very well, but I've found a few commits that make me believe that has been fixed. So my current setup I have working is the following: (require 'pymacs) (pymacs-load "ropemacs" "rope-") (add-hook 'python-mode-hook '(lambda () (eldoc-mode 1)) t) and thats it, this gives me the ability to have *some* code completion via M-/, but this completion doesn't work very well... for example if I import os and type os.p it'll give me path, but then if I type os.path.j it doesn't give me completion for join. The python-hook is to give me documentation support, so if I have os.path.join and hit C-c C-f i'll bring me up the documentation for the method/class my cursor is currently on, which works perfectly. So i'm turning to you guys in hopes that you will share with me what you've done to get good code completion and documentation working, since these are the 2 most important things to be, I will work on getting pyflake/pylint working once I have these 2 small things working well. My hope is that I can get some kind of configuration that uses anything, company, or autocomplete with rope so that I get some nice autocomplete menu along with something that integrates those menus with pydoc so I can see signatures of methods while I'm going through the autocomplete list. Thanks for any tips you may have :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.roehler at online.de Sun Dec 13 19:13:56 2009 From: andreas.roehler at online.de (Andreas Roehler) Date: Sun, 13 Dec 2009 19:13:56 +0100 Subject: [Python-mode] Problem with Multi-Line Comments In-Reply-To: References: <4B21188D.3030603@borg.org> <4B220319.8060700@online.de> <4B2253E9.5010506@borg.org> <4B228BE3.1030804@online.de> Message-ID: <4B252EE4.8020603@online.de> Barry Warsaw wrote: > On Dec 11, 2009, at 1:13 PM, Andreas Roehler wrote: > >> Already tried to tackle the issue. Works with GNU Emacs for me, not with XEmacs until now. >> Introduced some stuff from python.el - defconst python-font-lock-syntactic-keywords etc. >> >> Patch attached - not polished yet, but works here some weeks now. > > Why not push a branch to Launchpad so we can more easily play with it and diff it against trunk? > > :) > > -Barry > > Done