[issue44010] IDLE: highlight soft keywords

2021-11-06 Thread Rafael Fontenelle


Change by Rafael Fontenelle :


--
nosy: +rffontenelle
nosy_count: 5.0 -> 6.0
pull_requests: +27709
pull_request: https://github.com/python/cpython/pull/29454

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-25 Thread Tal Einat


Tal Einat  added the comment:

IMO this can be closed, so I'm closing this.  (Terry is welcome to reopen this 
if needed.)

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-25 Thread E. Paine


E. Paine  added the comment:

Can we close this, or are we leaving it open for when (if) we do a colouriser 
refactor?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-19 Thread miss-islington


miss-islington  added the comment:


New changeset 3357604db966693b752cbd9ffc3ad0f40b970d31 by Miss Islington (bot) 
in branch '3.10':
bpo-44010: IDLE: colorize pattern-matching soft keywords (GH-25851)
https://github.com/python/cpython/commit/3357604db966693b752cbd9ffc3ad0f40b970d31


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-19 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +24854
pull_request: https://github.com/python/cpython/pull/26237

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread Tal Einat


Tal Einat  added the comment:

I've created a PR (GH-25851) with a rather quick, working implementation.

This includes some tests but I haven't thoroughly tested it yet.

If anyone can take a look and give feedback on the approach, that would be 
great.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread Tal Einat


Change by Tal Einat :


--
keywords: +patch
pull_requests: +24534
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/25851

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread Tal Einat


Tal Einat  added the comment:

> A related request is to to syntax highlight field expressions in f strings.

Related, but separate, and IMO not quite as urgent.

I can commit to working on this issue (soft keywords), but I'll have to see 
where things stand once this is finished before moving on to f-strings.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I agree with getting this in soon.

A related request is to to syntax highlight field expressions in f strings.  I 
don't think there is an existing issue.  Apparently, at least some alternatives 
to IDLE do this.  I am not sure I would really want it, but we need at least 
some mockups.  Tal, what do you think and are you interested in trying to write 
a PR?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

My plan for the next day or two is to submit followup issue for Shell and 
formally code what I wrote.

The only way to handle soft keywords correctly is with a custom re.  I don't 
expect them to become common.  They are different from builtins because they 
only have special meaning in (so far) definable situations.  When  builtin is 
'redefined, it may or may not be appropriate to keep the highlight.  Examples 
when it is:

oldprint = print
def print(*args, **kwds:
log the print
oldprint(*args, **kwds)

def intsum(nums, int=int):  # Localize int for speed.


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread Tal Einat


Tal Einat  added the comment:

I think it is rather crucial to have this with the 3.10 release. I'll try to 
get this working ASAP.

I agree that a simple "good enough" solution could be a good start, but "_" 
will likely need special handling.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread E. Paine


E. Paine  added the comment:

I don't mind, would you like to Tal? (I probably won't be able to dedicate any 
serious time to it until mid-June). One thing I've been thinking is whether 
it's worth us highlighting regardless of context. For example, you can assign a 
variable to a builtin name (not that it's recommended) so we could just give 
soft keywords their own colour and (unofficially) recommend people don't use 
such words for variables.

I think this would be more future-proof as we wouldn't need to update the 
regexes for each new soft keyword added. However, we might not want to 
highlight every time the user has an '_' variable (as is fairly common).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-03 Thread Tal Einat


Tal Einat  added the comment:

Terry, Elisha, does one of you intend to work on this? If not, I'd be willing 
to.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-02 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Soft keywords are a huge nuisance for syntax highlighting as they need special 
case regexes and tests.

Hard keywords are matched against complete words, regardless of whether the 
context is syntactically valid or not.  If 'for' and 'else' were the only 
keywords, the keyword part of the IDLE colorizer regex would be as follows.

>>> kw = r"\b" + colorizer.any("KEYWORD", ['for', 'else']) + r"\b"
>>> kw
'\\b(?Pfor|else)\\b'

Both words in 'for.else' are highlighted as the tokenizer will see them as 
keywords.  The parser will later see the combination as an error.

The tag name in a "(?P...) construct can only be used once in a regex.  
Since the word-boundary context is the same for all hard keywords, the 
alternation can be done within one such context and all (hard) keywords get the 
same match tag (dict key "KEYWORD"), making it easy to give all the same 
highlight.

Soft keywords need different contexts to avoid false positives.  'match' and 
'case' must be the first non-blank on a line and followed by ':'.  '_' must 
follow 'case' and space. I believe each context will have to have its own tag 
name, so multiple keyword tags must be mapped to 'keyword'.  

skw1 = r"^[ \t]*(?Pmatch|case)[ \t]+:"
skw2 = r"case[ \t]+(?P_)\b"

Add skw1 and skw2 to the prog definition, which should use "|".join(...).

In ColorDelegator.LoadTagDefs (which should be renamed), replace

"KEYWORD": idleConf.GetHighlight(theme, "keyword"),

with
"KEYWORD": keydef
"SKEY1": keydef
"SKEY2": keydef

after first defining keydef with

keydef = idleConf.GetHighlight(theme, "keyword")

Some new tests will be needed.

--
stage:  -> test needed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44010] IDLE: highlight soft keywords

2021-05-02 Thread E. Paine


E. Paine  added the comment:

Thanks for linking to the Lexical Analysis docs. Not quite sure how I missed 
this given it is directly below the normal keywords section. Given the 
distinction described there, it may instead be best for IDLE to highlight this 
as its own category (i.e. not grouping it with the standard keywords).

--
title: IDLE: highlight new `match` / `case` syntax -> IDLE: highlight soft 
keywords

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com