From noreply at sourceforge.net Thu Aug 9 03:53:47 2007 From: noreply at sourceforge.net (SourceForge.net) Date: Wed, 08 Aug 2007 18:53:47 -0700 Subject: [Python-mode] [ python-mode-Patches-1770556 ] Handle triple-quoted strings correctly: take 2 Message-ID: Patches item #1770556, was opened at 2007-08-08 21:53 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1770556&group_id=86916 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Edward Loper (edloper) Assigned to: Nobody/Anonymous (nobody) Summary: Handle triple-quoted strings correctly: take 2 Initial Comment: This patch uses font-lock-mode's syntactic keyword feature to ensure that triple quoted strings are displayed correctly. In particular, it defines a font-lock-syntactic-keywords table that finds any quote marks that should not be considered string delimiters because they occur inside triple-quoted strings, and sets their syntactic designation to "normal punctuation" (the same designation used for e.g. operators). This is a more principled approach than my previous attempt to fix python-mode's handling of triple-quoted strings [1], and as a result the patch is about a third as big, and should never incur any serious overhead. This patch has been tested successfully on the following emacs variants: XEmacs 21.4 (patch 13) (i386-redhat-linux) XEmacs 21.4 (patch 17) (i386-debian-linux) GNU Emacs 21.3.1 (i386-wingw-nt5.1.2600) GNU Emacs 21.3.1 (i386-redhat-linux-gnu) GNU Emacs 22.0.50.1 (powerpc-apple-darwin8.3.0) I am also including the file test-triple-strings.py, which contains a bunch of test cases to make sure the mode is working correctly. This file is *not* intended to be run -- it is intended to be opened in python-mode, and examined by hand to verify that the correct faces are used. I included test cases for every corner case that I thought of (e.g. interactions between backslashes and quotes, and cases with more than 3 quotes in a row). The new behavior can be turned off using the customization constant "py-syntactic-triple-quoted-strings" (default=t), but I don't expect that to ever be necessary. I am retiring my previous patch with the same goal [1] -- this patch supsercedes it. If this patch looks acceptable, let me know, and I can commit it. (Or feel free to commit it yourself.) It might be good to include the test file, possibly in a "tests/" subdirectory. [1] http://sourceforge.net/tracker/index.php?func=detail&aid=1023335&group_id=86916&atid=581351 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1770556&group_id=86916 From noreply at sourceforge.net Thu Aug 9 03:54:58 2007 From: noreply at sourceforge.net (SourceForge.net) Date: Wed, 08 Aug 2007 18:54:58 -0700 Subject: [Python-mode] [ python-mode-Patches-1023335 ] Handle triple-quoted strings correctly. Message-ID: Patches item #1023335, was opened at 2004-09-06 18:22 Message generated for change (Comment added) made by edloper You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1023335&group_id=86916 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed Resolution: None Priority: 5 Private: No Submitted By: Edward Loper (edloper) Assigned to: Edward Loper (edloper) Summary: Handle triple-quoted strings correctly. Initial Comment: This patch adds an option that will color triple-quoted strings correctly. It works by turning off syntax-highlighting for strings and comments (by registering quotes and hashes in the syntax table as normal punctuation); and using a fairly advanced keyword matcher to find all strings and comments. The keyword matcher uses a text- property to keep track of the syntax category of each character, and only updates it as needed. Therefore, the option can only be used if text-properties are available (but they are available on all current versions of emacs, as far as I know). Caveat: it's possible that this will be slow on some machines, or under certian circumstances. But it's not noticably slower on the machines & files I've tested it on. ---------------------------------------------------------------------- >Comment By: Edward Loper (edloper) Date: 2007-08-08 21:54 Message: Logged In: YES user_id=195958 Originator: YES Closing -- this patch is superceded by patch #1770556: http://sourceforge.net/tracker/index.php?func=detail&aid=1770556&group_id=86916&atid=581351 ---------------------------------------------------------------------- Comment By: Ethan Glasser-Camp (glasserc) Date: 2007-03-28 00:50 Message: Logged In: YES user_id=270121 Originator: NO I tried this on XEmacs and it worked fine so far as I could tell. Thanks a ton! XEmacs 21.4 (patch 20) "Double Solitaire" [Lucid] (i486-linux-gnu, Mule) of Sun Mar 25 2007 on penell Ethan ---------------------------------------------------------------------- Comment By: Edward Loper (edloper) Date: 2006-03-11 01:07 Message: Logged In: YES user_id=195958 I have attached a new version of the patch, which should hopefully address both Skip's issue, and the problem that Johannes Gijsbers pointed out. I'd appreciate it if several people could try it out (preferably on both emacs and xemacs), and let me know if it works. danielx_: download the patch file (handle-tqs-v2.diff) at the bottom of this page, and run "patch python-mode.el handle-tqs-v2.diff". The changes I made were: - removed (require 'text-properties), since 'text- properties isn't defined as a feature in emacs; and it should be available by default in both xemacs and emacs, anyway. - Replaced calls to "replace-regexp-in-string" with a compatibility function "py-replace-regexp-in-string", since the former is only available on xemacs. - Fixed a bug in the regexp used to find the end of comments (this was what caused problems in BaseHTTPServer.py). ---------------------------------------------------------------------- Comment By: Daniel (danielx_) Date: 2005-11-19 18:43 Message: Logged In: YES user_id=1383230 Sorry, how do I install this? I'm using python-mode ver1.0alpha, found on the "Files" page. ---------------------------------------------------------------------- Comment By: Skip Montanaro (montanaro) Date: 2005-06-04 16:46 Message: Logged In: YES user_id=44345 Ed, this looks like this would be a good addition, but there are some problems. Is there any resolution to Johannes' note about comment breakage? I just patched my copy of python-mode.el. When I visit a .py file it complains that it can't find the text-properties package. (This is XEmacs 21.4.15.) I didn't see anything like text-properties or properties in the package list. ---------------------------------------------------------------------- Comment By: Johannes Gijsbers (jlgijsbers) Date: 2004-11-01 11:15 Message: Logged In: YES user_id=469548 I applied this patch to the latest python-mode and while triple-quoted-strings mostly work fine (thank you! thank you! thank you!), comments seem to be a bit broken. Take a look at BaseHTTPServer.py from the Python CVS for a particularly bad example. I'm running "GNU Emacs 21.3.50.1 (i386-pc-linux-gnu, GTK+ Version 2.4.10) of 2004-10-11 on surfboy, modified by Debian", compiled from Emacs CVS using the emacs-snapshot package. ---------------------------------------------------------------------- Comment By: Edward Loper (edloper) Date: 2004-09-06 22:15 Message: Logged In: YES user_id=195958 So I did. Trying again. ---------------------------------------------------------------------- Comment By: Skip Montanaro (montanaro) Date: 2004-09-06 21:41 Message: Logged In: YES user_id=44345 Edward, perhaps you forgot to check the box when uploading the patch? There's nothing currently attached to this item. -Skip ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1023335&group_id=86916 From noreply at sourceforge.net Thu Aug 9 03:55:29 2007 From: noreply at sourceforge.net (SourceForge.net) Date: Wed, 08 Aug 2007 18:55:29 -0700 Subject: [Python-mode] [ python-mode-Patches-1770556 ] Handle triple-quoted strings correctly: take 2 Message-ID: Patches item #1770556, was opened at 2007-08-08 21:53 Message generated for change (Comment added) made by edloper You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1770556&group_id=86916 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Edward Loper (edloper) Assigned to: Nobody/Anonymous (nobody) Summary: Handle triple-quoted strings correctly: take 2 Initial Comment: This patch uses font-lock-mode's syntactic keyword feature to ensure that triple quoted strings are displayed correctly. In particular, it defines a font-lock-syntactic-keywords table that finds any quote marks that should not be considered string delimiters because they occur inside triple-quoted strings, and sets their syntactic designation to "normal punctuation" (the same designation used for e.g. operators). This is a more principled approach than my previous attempt to fix python-mode's handling of triple-quoted strings [1], and as a result the patch is about a third as big, and should never incur any serious overhead. This patch has been tested successfully on the following emacs variants: XEmacs 21.4 (patch 13) (i386-redhat-linux) XEmacs 21.4 (patch 17) (i386-debian-linux) GNU Emacs 21.3.1 (i386-wingw-nt5.1.2600) GNU Emacs 21.3.1 (i386-redhat-linux-gnu) GNU Emacs 22.0.50.1 (powerpc-apple-darwin8.3.0) I am also including the file test-triple-strings.py, which contains a bunch of test cases to make sure the mode is working correctly. This file is *not* intended to be run -- it is intended to be opened in python-mode, and examined by hand to verify that the correct faces are used. I included test cases for every corner case that I thought of (e.g. interactions between backslashes and quotes, and cases with more than 3 quotes in a row). The new behavior can be turned off using the customization constant "py-syntactic-triple-quoted-strings" (default=t), but I don't expect that to ever be necessary. I am retiring my previous patch with the same goal [1] -- this patch supsercedes it. If this patch looks acceptable, let me know, and I can commit it. (Or feel free to commit it yourself.) It might be good to include the test file, possibly in a "tests/" subdirectory. [1] http://sourceforge.net/tracker/index.php?func=detail&aid=1023335&group_id=86916&atid=581351 ---------------------------------------------------------------------- >Comment By: Edward Loper (edloper) Date: 2007-08-08 21:55 Message: Logged In: YES user_id=195958 Originator: YES File Added: test-triple-strings.py ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1770556&group_id=86916 From noreply at sourceforge.net Fri Aug 10 09:07:19 2007 From: noreply at sourceforge.net (SourceForge.net) Date: Fri, 10 Aug 2007 00:07:19 -0700 Subject: [Python-mode] [ python-mode-Patches-1770556 ] Handle triple-quoted strings correctly: take 2 Message-ID: Patches item #1770556, was opened at 2007-08-08 20:53 Message generated for change (Comment added) made by glasserc You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1770556&group_id=86916 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Edward Loper (edloper) Assigned to: Nobody/Anonymous (nobody) Summary: Handle triple-quoted strings correctly: take 2 Initial Comment: This patch uses font-lock-mode's syntactic keyword feature to ensure that triple quoted strings are displayed correctly. In particular, it defines a font-lock-syntactic-keywords table that finds any quote marks that should not be considered string delimiters because they occur inside triple-quoted strings, and sets their syntactic designation to "normal punctuation" (the same designation used for e.g. operators). This is a more principled approach than my previous attempt to fix python-mode's handling of triple-quoted strings [1], and as a result the patch is about a third as big, and should never incur any serious overhead. This patch has been tested successfully on the following emacs variants: XEmacs 21.4 (patch 13) (i386-redhat-linux) XEmacs 21.4 (patch 17) (i386-debian-linux) GNU Emacs 21.3.1 (i386-wingw-nt5.1.2600) GNU Emacs 21.3.1 (i386-redhat-linux-gnu) GNU Emacs 22.0.50.1 (powerpc-apple-darwin8.3.0) I am also including the file test-triple-strings.py, which contains a bunch of test cases to make sure the mode is working correctly. This file is *not* intended to be run -- it is intended to be opened in python-mode, and examined by hand to verify that the correct faces are used. I included test cases for every corner case that I thought of (e.g. interactions between backslashes and quotes, and cases with more than 3 quotes in a row). The new behavior can be turned off using the customization constant "py-syntactic-triple-quoted-strings" (default=t), but I don't expect that to ever be necessary. I am retiring my previous patch with the same goal [1] -- this patch supsercedes it. If this patch looks acceptable, let me know, and I can commit it. (Or feel free to commit it yourself.) It might be good to include the test file, possibly in a "tests/" subdirectory. [1] http://sourceforge.net/tracker/index.php?func=detail&aid=1023335&group_id=86916&atid=581351 ---------------------------------------------------------------------- Comment By: Ethan Glasser-Camp (glasserc) Date: 2007-08-10 02:07 Message: Logged In: YES user_id=270121 Originator: NO Hi, I'm not qualified to review your patch, but I did test it on my machine: XEmacs 21.4 (patch 20) (i386-debian-linux). It works better than the last patch, including not being confused by colons or parens inside strings. Thanks for your time and effort! Ethan ---------------------------------------------------------------------- Comment By: Edward Loper (edloper) Date: 2007-08-08 20:55 Message: Logged In: YES user_id=195958 Originator: YES File Added: test-triple-strings.py ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581351&aid=1770556&group_id=86916 From noreply at sourceforge.net Fri Aug 17 03:55:30 2007 From: noreply at sourceforge.net (SourceForge.net) Date: Thu, 16 Aug 2007 18:55:30 -0700 Subject: [Python-mode] [ python-mode-Bugs-1775975 ] python-mode docstrings syntax bug Message-ID: Bugs item #1775975, was opened at 2007-08-17 09:55 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581349&aid=1775975&group_id=86916 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: v1.0 (example) Status: Open Resolution: None Priority: 5 Private: No Submitted By: Border (borderj) Assigned to: Nobody/Anonymous (nobody) Summary: python-mode docstrings syntax bug Initial Comment: These Emacs parsing functions are configurable, but not quite configurable enough to capture all of Python's rules. like: print """ "Hi!" I'm a doc string""" print ''' 'Hi!' I'm a doc string''' print """ ''' "Hi!" I'm a doc string ''' """ print ''' """ "Hi!" I'm a doc string """ ''' something like """ "Hi!" I'm a doc string """ Emacs "sees" it as a sequence of 4 strings with some crap in the middle: "" "\n " Hi! " I'm a doc string\n " "" Emacs : GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on RELEASE Package: python-mode $Revision: 4.75 $ current state: ============== (setq py-python-command "python" py-indent-offset 4 py-block-comment-prefix "##" py-temp-directory "c:/DOCUME~1/new/LOCALS~1/Temp" py-beep-if-tab-change t ) -- Blog: www.borderj.cn Border ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=581349&aid=1775975&group_id=86916 From borderj at gmail.com Wed Aug 15 05:04:51 2007 From: borderj at gmail.com (=?UTF-8?B?6L6544CA5rGf?=) Date: Wed, 15 Aug 2007 03:04:51 -0000 Subject: [Python-mode] python-mode $Revision: 4.75 $; python-mode syntax """ ''' bug Message-ID: Dear Barry, These Emacs parsing functions are configurable, but not quite configurable enough to capture all of Python's rules. like: print """ "Hi!" I'm a doc string""" print ''' 'Hi!' I'm a doc string''' print """ ''' "Hi!" I'm a doc string ''' """ print ''' """ "Hi!" I'm a doc string """ ''' Emacs : GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on RELEASE Package: python-mode $Revision: 4.75 $ current state: ============== (setq py-python-command "python" py-indent-offset 4 py-block-comment-prefix "##" py-temp-directory "c:/DOCUME~1/new/LOCALS~1/Temp" py-beep-if-tab-change t ) -- Blog: www.borderj.cn MSN: borderj at live.com Border -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-mode/attachments/20070815/cae220ad/attachment.htm