unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41684: [PATCH] Highlight typed variables in python
@ 2020-06-03 11:51 Konstantin Kharlamov
  2020-06-09 23:12 ` Konstantin Kharlamov
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Konstantin Kharlamov @ 2020-06-03 11:51 UTC (permalink / raw)
  To: 41684

* progmodes/python.el (python-font-lock-keywords-maximum-decoration):
recognize typed variables like "foo: int = 1" as well.
---

Hello! This is the patch originally posted here 

https://lists.gnu.org/archive/html/emacs-devel/2020-06/msg00033.html

I forgot in Emacs patches has to be sent to bugtracker. So here's the
resend.

 lisp/progmodes/python.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ae5aff351c0..0263f4cc291 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -634,6 +634,7 @@ python-font-lock-keywords-maximum-decoration
     (,(lambda (limit)
         (let ((re (python-rx (group (+ (any word ?. ?_)))
                              (? ?\[ (+ (not (any  ?\]))) ?\]) (* space)
+                             (? ?: (* space) (+ (any word ?. ?_)) (* space)) ;; a type, like " : int "
                              assignment-operator))
               (res nil))
           (while (and (setq res (re-search-forward re limit t))
-- 
2.26.2






^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-03 11:51 bug#41684: [PATCH] Highlight typed variables in python Konstantin Kharlamov
@ 2020-06-09 23:12 ` Konstantin Kharlamov
  2020-06-13  7:35 ` Eli Zaretskii
  2020-06-13 20:01 ` Andrii Kolomoiets
  2 siblings, 0 replies; 9+ messages in thread
From: Konstantin Kharlamov @ 2020-06-09 23:12 UTC (permalink / raw)
  To: 41684

ping






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-03 11:51 bug#41684: [PATCH] Highlight typed variables in python Konstantin Kharlamov
  2020-06-09 23:12 ` Konstantin Kharlamov
@ 2020-06-13  7:35 ` Eli Zaretskii
  2020-06-13  8:57   ` Konstantin Kharlamov
  2020-06-13 20:01 ` Andrii Kolomoiets
  2 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-06-13  7:35 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: 41684-done

> From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> Date: Wed,  3 Jun 2020 14:51:03 +0300
> 
> * progmodes/python.el (python-font-lock-keywords-maximum-decoration):
> recognize typed variables like "foo: int = 1" as well.
> ---

Thanks, I installed this on the master branch.

For the future, please note a couple of minor stylistic nits:

  . it is better to submit patches in "git format-patch" format, as
    that makes it easier to apply the patch
  . the description in the log message should start with a capital
    letter after the function's name
  . if a comment or a code line exceeds 80 columns, break them into
    several lines





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-13  7:35 ` Eli Zaretskii
@ 2020-06-13  8:57   ` Konstantin Kharlamov
  2020-06-13  9:15     ` Eli Zaretskii
  2020-06-13 10:44     ` Basil L. Contovounesios
  0 siblings, 2 replies; 9+ messages in thread
From: Konstantin Kharlamov @ 2020-06-13  8:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 41684-done

On Sat, 2020-06-13 at 10:35 +0300, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> > Date: Wed,  3 Jun 2020 14:51:03 +0300
> > 
> > * progmodes/python.el (python-font-lock-keywords-maximum-
> > decoration):
> > recognize typed variables like "foo: int = 1" as well.
> > ---
> 
> Thanks, I installed this on the master branch.

Thanks!

> For the future, please note a couple of minor stylistic nits:
> 
>   . it is better to submit patches in "git format-patch" format, as
>     that makes it easier to apply the patch

Hmm, okay… The patch was sent with git-send-email command, is it
different from git-format-patch? I used to see projects that in our
days still use (or have used) email for patches recommend specifically
sending patches with git-send-email, so it is a bit unusual
requirement, but I'll try to remember.

>   . the description in the log message should start with a capital
>     letter after the function's name

Okay, thanks. I'll try to remember, although it is unusual too, because
AFAIK from grammar standpoint a sentence continuation after a colon ":"
symbol should be lower-case.

>   . if a comment or a code line exceeds 80 columns, break them into
>     several lines






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-13  8:57   ` Konstantin Kharlamov
@ 2020-06-13  9:15     ` Eli Zaretskii
  2020-06-13  9:21       ` Konstantin Kharlamov
  2020-06-13 10:44     ` Basil L. Contovounesios
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-06-13  9:15 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: 41684

> From: Konstantin Kharlamov <hi-angel@yandex.ru>
> Cc: 41684-done@debbugs.gnu.org
> Date: Sat, 13 Jun 2020 11:57:44 +0300
> 
> >   . it is better to submit patches in "git format-patch" format, as
> >     that makes it easier to apply the patch
> 
> Hmm, okay… The patch was sent with git-send-email command, is it
> different from git-format-patch?

It isn't how you send the patches that's the issue, it's the way you
produced the patch.  AFAIK, git-send-email accepts patches formatted
with git-format-patch, but it doesn't look like you used the latter to
produce a patch.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-13  9:15     ` Eli Zaretskii
@ 2020-06-13  9:21       ` Konstantin Kharlamov
  0 siblings, 0 replies; 9+ messages in thread
From: Konstantin Kharlamov @ 2020-06-13  9:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 41684

On Sat, 2020-06-13 at 12:15 +0300, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <hi-angel@yandex.ru>
> > Cc: 41684-done@debbugs.gnu.org
> > Date: Sat, 13 Jun 2020 11:57:44 +0300
> > 
> > >   . it is better to submit patches in "git format-patch" format,
> > > as
> > >     that makes it easier to apply the patch
> > 
> > Hmm, okay… The patch was sent with git-send-email command, is it
> > different from git-format-patch?
> 
> It isn't how you send the patches that's the issue, it's the way you
> produced the patch.  AFAIK, git-send-email accepts patches formatted
> with git-format-patch, but it doesn't look like you used the latter
> to
> produce a patch.

Thanks, right, I haven't used any other command except git-send-email.
Specifically, I have executed  `git send-email -1 --annotate` and then
filled in required fields.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-13  8:57   ` Konstantin Kharlamov
  2020-06-13  9:15     ` Eli Zaretskii
@ 2020-06-13 10:44     ` Basil L. Contovounesios
  1 sibling, 0 replies; 9+ messages in thread
From: Basil L. Contovounesios @ 2020-06-13 10:44 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: 41684

Konstantin Kharlamov <hi-angel@yandex.ru> writes:

>>   . the description in the log message should start with a capital
>>     letter after the function's name
>
> Okay, thanks. I'll try to remember, although it is unusual too, because
> AFAIK from grammar standpoint a sentence continuation after a colon ":"
> symbol should be lower-case.

Yes, but in this case the colon is part of the change log markup, not
the sentence.  The sentence starts after the colon.

Thanks,

-- 
Basil





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-03 11:51 bug#41684: [PATCH] Highlight typed variables in python Konstantin Kharlamov
  2020-06-09 23:12 ` Konstantin Kharlamov
  2020-06-13  7:35 ` Eli Zaretskii
@ 2020-06-13 20:01 ` Andrii Kolomoiets
  2020-06-13 20:40   ` Konstantin Kharlamov
  2 siblings, 1 reply; 9+ messages in thread
From: Andrii Kolomoiets @ 2020-06-13 20:01 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: 41684

Hi Konstantin,

> * progmodes/python.el (python-font-lock-keywords-maximum-decoration):
> recognize typed variables like "foo: int = 1" as well.

Good work!

Any plans to recognize typed variables like "foo: List[int] = [1]" as
well? ;-)





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#41684: [PATCH] Highlight typed variables in python
  2020-06-13 20:01 ` Andrii Kolomoiets
@ 2020-06-13 20:40   ` Konstantin Kharlamov
  0 siblings, 0 replies; 9+ messages in thread
From: Konstantin Kharlamov @ 2020-06-13 20:40 UTC (permalink / raw)
  To: Andrii Kolomoiets; +Cc: 41684

On Sat, 2020-06-13 at 23:01 +0300, Andrii Kolomoiets wrote:
> Hi Konstantin,
> 
> > * progmodes/python.el (python-font-lock-keywords-maximum-decoration):
> > recognize typed variables like "foo: int = 1" as well.
> 
> Good work!
> 
> Any plans to recognize typed variables like "foo: List[int] = [1]" as
> well? ;-)

Thank you for the follow up! This is a good example to improve upon, I haven't
thought about it. I don't currently have plans, so if you wanted that, sure go
for it :) I'm mostly sending improvements as I work with Python at may dayjob, I
wasn't stumbling upon such construction there, so I'm not too worried just yet.

FTR: if anybody is interested why this font-lock-variable-face matters, the
color-identifiers-mode uses it to highlight identifiers in code with different
colors. Immensely helps in reading the code.






^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-13 20:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 11:51 bug#41684: [PATCH] Highlight typed variables in python Konstantin Kharlamov
2020-06-09 23:12 ` Konstantin Kharlamov
2020-06-13  7:35 ` Eli Zaretskii
2020-06-13  8:57   ` Konstantin Kharlamov
2020-06-13  9:15     ` Eli Zaretskii
2020-06-13  9:21       ` Konstantin Kharlamov
2020-06-13 10:44     ` Basil L. Contovounesios
2020-06-13 20:01 ` Andrii Kolomoiets
2020-06-13 20:40   ` Konstantin Kharlamov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).