GNU bug report logs - #15161
24.3; python mode highlight annoyance

Previous Next

Package: emacs;

Reported by: Alexis Roda <alexis.roda.villalonga <at> gmail.com>

Date: Thu, 22 Aug 2013 15:46:01 UTC

Severity: minor

Found in version 24.3

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: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#15161: closed (24.3; python mode highlight annoyance)
Date: Tue, 27 Aug 2013 02:43:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 26 Aug 2013 22:42:39 -0400
with message-id <jwvd2oz6ejd.fsf-monnier+emacs <at> gnu.org>
and subject line Re: bug#15161: 24.3; python mode highlight annoyance
has caused the debbugs.gnu.org bug report #15161,
regarding 24.3; python mode highlight annoyance
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
15161: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15161
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Alexis Roda <alexis.roda.villalonga <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; python mode highlight annoyance
Date: Thu, 22 Aug 2013 13:12:09 +0200
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)


[Message part 3 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alexis Roda <alexis.roda.villalonga <at> gmail.com>
Cc: "Fabián E. Gallina" <fabian <at> anue.biz>,
 15161-done <at> debbugs.gnu.org
Subject: Re: bug#15161: 24.3; python mode highlight annoyance
Date: Mon, 26 Aug 2013 22:42:39 -0400
> # 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



This bug report was last modified 11 years and 363 days ago.

Previous Next


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