GNU bug report logs - #7322
Something about python font-lock

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Wed, 3 Nov 2010 11:44:02 UTC

Severity: normal

Found in version 23.1

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Subject: bug#7322: closed (Re: bug#7322: 23.1; tqs-escape-syntax-error)
Date: Mon, 08 Nov 2010 18:56:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#7322: Something about python font-lock

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 7322 <at> debbugs.gnu.org.

-- 
7322: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7322
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Subject: Re: bug#7322: 23.1; tqs-escape-syntax-error
Date: Mon, 08 Nov 2010 13:57:34 -0500
>>>>> "Andreas" == Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

> Hi,

> editing python code, the following code concatenates strings with variables:

> """(beginning-of-form-base \"""" + string1 + """\" \"""" + string2 + """\"
> nil nil nil nil t))))"""

> while " + string1 +" is highlighted correctly, " + string2 + " has string
> face wrongly.

Thanks.  Indeed backslashes weren't recognized properly in this case.
I've installed the patch below in the emacs-23 branch, which seems to
fix this problem.


        Stefan


=== modified file 'lisp/progmodes/python.el'
--- lisp/progmodes/python.el	2010-08-23 00:44:55 +0000
+++ lisp/progmodes/python.el	2010-11-08 18:53:30 +0000
@@ -170,18 +170,9 @@
   ;; Make outer chars of matching triple-quote sequences into generic
   ;; string delimiters.  Fixme: Is there a better way?
   ;; First avoid a sequence preceded by an odd number of backslashes.
-  `((,(rx (not (any ?\\))
-	  ?\\ (* (and ?\\ ?\\))
-	  (group (syntax string-quote))
-	  (backref 1)
-	  (group (backref 1)))
-     (2 ,(string-to-syntax "\"")))	; dummy
-    (,(rx (group (optional (any "uUrR"))) ; prefix gets syntax property
-	  (optional (any "rR"))		  ; possible second prefix
-	  (group (syntax string-quote))   ; maybe gets property
-	  (backref 2)			  ; per first quote
-	  (group (backref 2)))		  ; maybe gets property
-     (1 (python-quote-syntax 1))
+  `((,(concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix.
+              "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)")
+     (1 (python-quote-syntax 1) nil lax)
      (2 (python-quote-syntax 2))
      (3 (python-quote-syntax 3)))
     ;; This doesn't really help.
@@ -219,9 +210,9 @@
 	      (eval-when-compile (string-to-syntax "|"))))))
      ;; Consider property for initial char, accounting for prefixes.
      ((or (and (= n 2)			; leading quote (not prefix)
-	       (= (match-beginning 1) (match-end 1))) ; prefix is null
+	       (not (match-end 1)))     ; prefix is null
 	  (and (= n 1)			; prefix
-	       (/= (match-beginning 1) (match-end 1)))) ; non-empty
+	       (match-end 1)))          ; non-empty
       (let ((font-lock-syntactic-keywords nil))
 	(unless (eq 'string (syntax-ppss-context (syntax-ppss)))
 	  (eval-when-compile (string-to-syntax "|")))))


[Message part 3 (message/rfc822, inline)]
From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; tqs-escape-syntax-error
Date: Wed, 03 Nov 2010 12:47:12 +0100
Hi,

editing python code, the following code concatenates strings with variables:

"""(beginning-of-form-base \"""" + string1 + """\" \"""" + string2 + 
"""\" nil nil nil nil t))))"""

while " + string1 +" is highlighted correctly, " + string2 + " has 
string face wrongly.

Also `ppss' falsely indicates being inside a string.

BTW everything is fine with an alternative coding using
singlequotes:

"""(beginning-of-form-base \"""" + string1 + '\" \"' + string2 + """\" 
nil nil nil nil t))))"""

The bug however exists.

Thanks all


Andreas

--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/



In GNU Emacs 23.1.1 (i586-suse-linux-gnu, GTK+ Version 2.20.1)
 of 2010-07-05
Windowing system distributor `The X.Org Foundation', version 11.0.10800000
configured using `configure  '--with-pop' '--without-hesiod' 
'--with-kerberos' '--with-kerberos5' '--with-xim' '--prefix=/usr' 
'--mandir=/usr/share/man' '--infodir=/usr/share/info' 
'--datadir=/usr/share' '--localstatedir=/var' 
'--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--with-x' 
'--with-sound' '--with-sync-input' '--with-xpm' '--with-jpeg' 
'--with-tiff' '--with-gif' '--with-png' '--with-rsvg' '--with-dbus' 
'--without-gpm' '--with-x-toolkit=gtk' '--x-includes=/usr/include' 
'--x-libraries=/usr/lib:/usr/share/X11' '--with-xft' '--with-libotf' 
'--with-m17n-flt' '--build=i586-suse-linux' 
'build_alias=i586-suse-linux' 'CC=gcc-4.3' 'CFLAGS=-fomit-frame-pointer 
-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector 
-funwind-tables -fasynchronous-unwind-tables -g -D_GNU_SOURCE -std=gnu89 
-pipe -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label 
-Wno-unprototyped-calls -fno-optimize-sibling-calls 
-DSYSTEM_PURESIZE_EXTRA=55000 	 -DSITELOAD_PURESIZE_EXTRA=10000 ' 
'LDFLAGS=-Wl,-O2 -Wl,--hash-size=65521''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: de_DE.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Python

Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <up> <up> <up> <up>
<up> <up> <up> <left> <left> <left> C-j <up> ; ; SPC
<down> <left> C-x C-e C-x C-f p r o g a r <tab> p o
y <tab> <backspace> <backspace> y t <tab> t h <tab>
l i s t <tab> a <tab> <return> <next> <next> <next>
<next> <next> <next> <next> <next> <next> <next> <next>
<next> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <left> <up>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <help-echo>
C-h f p y t h o n m <backspace> - m o d e <return>
C-x 1 M-x r e p o r t - e m a c s - b u <tab> <ret
urn>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark saved where search started
Mark set




This bug report was last modified 14 years and 197 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.