Subject: bug#15161: closed (Re: bug#15161: 24.3; python mode highlight annoyance)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 27 Aug 2013 02:43:02 +0000

Your bug report

#15161: 24.3; python mode highlight annoyance

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 [email-masked].

-- 
15161: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15161
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#15161: 24.3; python mode highlight annoyance
From: Stefan Monnier <[email-masked]>
To: Alexis Roda <[email-masked]>
Cc: "Fabián E. Gallina" <[email-masked]>, [email-masked]
Date: Mon, 26 Aug 2013 22:42:39 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> # a ==
> variable = "value"

> save, close and open the file again, the variable identifier isn't
> properly highlighted.

Thanks.  I installed the patch below which should fix it,

        Stefan

=== modified file 'lisp/progmodes/python.el'
--- lisp/progmodes/python.el	2013-08-16 05:15:51 +0000
+++ lisp/progmodes/python.el	2013-08-27 02:37:53 +0000
@@ -501,29 +501,24 @@
     (,(lambda (limit)
         (let ((re (python-rx (group (+ (any word ?. ?_)))
                              (? ?\[ (+ (not (any  ?\]))) ?\]) (* space)
-                             assignment-operator)))
-          (when (re-search-forward re limit t)
-            (while (and (python-syntax-context 'paren)
-                        (re-search-forward re limit t)))
-            (if (not (or (python-syntax-context 'paren)
-                         (equal (char-after (point-marker)) ?=)))
-                t
-              (set-match-data nil)))))
+                             assignment-operator))
+              (res nil))
+          (while (and (setq res (re-search-forward re limit t))
+                      (or (python-syntax-context 'paren)
+                          (equal (char-after (point-marker)) ?=))))
+          res))
      (1 font-lock-variable-name-face nil nil))
     ;; support for a, b, c = (1, 2, 3)
     (,(lambda (limit)
         (let ((re (python-rx (group (+ (any word ?. ?_))) (* space)
                              (* ?, (* space) (+ (any word ?. ?_)) (* space))
                              ?, (* space) (+ (any word ?. ?_)) (* space)
-                             assignment-operator)))
-          (when (and (re-search-forward re limit t)
-                     (goto-char (nth 3 (match-data))))
-            (while (and (python-syntax-context 'paren)
-                        (re-search-forward re limit t))
-              (goto-char (nth 3 (match-data))))
-            (if (not (python-syntax-context 'paren))
-                t
-              (set-match-data nil)))))
+                             assignment-operator))
+              (res nil))
+          (while (and (setq res (re-search-forward re limit t))
+                      (goto-char (match-end 1))
+                      (python-syntax-context 'paren)))
+          res))
      (1 font-lock-variable-name-face nil nil))))
 
 (defconst python-syntax-propertize-function

Subject: 24.3; python mode highlight annoyance
From: Alexis Roda <[email-masked]>
To: [email-masked]
Date: Thu, 22 Aug 2013 13:12:09 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

The symptom is that in the code:

     # no s'ha trobat cap oferta, l'alumne queda sense assignar
     # (alumne.assignacio == None)
     self._logger.info(
          u"no assigna '%s'",
          alumne.id
          )
     alumne.assignacio = None

'alumne.assignacio' isn't properly colorized after visiting the file.

In order to reproduce this behaviour:

emacs -Q /tmp/bugtest.py

type:

# a ==
variable = "value"

save, close and open the file again, the variable identifier isn't
properly highlighted.

Deleting the 'a' or a '=' in the comment produces the right
colorization, but adding them back makes it wrong again.

In GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.2)
  of 2013-08-17 on superjul
Windowing system distributor `The X.Org Foundation', version 11.0.11300000
System Description:	Ubuntu 12.04.2 LTS

Configured using:
  `configure '--prefix=/opt/emacs/24.3''

Important settings:
   value of $LANG: ca_ES.UTF-8
   locale-coding-system: utf-8-unix
   default enable-multibyte-characters: t

Major mode: Python

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

Recent input:
<down> <down> <return> # SPC a = = <return> s o v e
_ <backspace> <backspace> <backspace> m e _ v a r SPC
= SPC 4 <return> <up> <up> <right> <right> <right>
SPC <end> <return> o t h e r SPC v a r <backspace>
<backspace> <backspace> <backspace> _ v a r SPC = SPC
4 <up> <right> <up> <right> <right> <right> <delete>
SPC <backspace> <end> <backspace> = <left> <left> <end>
<return> # SPC f o o <return> <backspace> <up> <left>
<left> SPC <backspace> <down> C-a C-k C-k M-x r e p
o <tab> r <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils help-mode python rx easymenu comint ring
ansi-color time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)