GNU bug report logs -
#30750
25.3; New Python3.6 f-string syntax highlighting support (feature request)
Previous Next
Reported by: Campbell Barton <ideasman42 <at> gmail.com>
Date: Thu, 8 Mar 2018 12:10:02 UTC
Severity: wishlist
Tags: confirmed
Found in version 25.3
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 30750 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I wonder if MagicPython project could be useful to implement this.
Currently, it has a pretty comprehensive test suit:
https://github.com/MagicStack/MagicPython/tree/master/test/fstrings
And it has f-strings grammar defined in a yaml file:
https://github.com/MagicStack/MagicPython/blob/master/grammars/src/pyfstring.inc.syntax.yaml
At the very least, it could serve as a widely adopted reference (Atom,
Sublime, and VS Code use it).
I also wrote a very naive and wrong hack for personal use, based on
php-mode:
```
(defconst python-f-string-regexp
"{[[:word:]]+\\.?[[:word:]]+?}")
(defun python-f-string-font-lock-find (limit)
(while (re-search-forward python-f-string-regexp limit t)
(when (python-syntax-comment-or-string-p)
(put-text-property (match-beginning 0) (match-end 0)
'face 'font-lock-variable-name-face)))
nil)
(with-eval-after-load 'python
(font-lock-add-keywords
'python-mode
`((python-f-string-font-lock-find))
'append))
```
(I'm really sorry, I don't know how to format monospaced text in debbugs)
[Message part 2 (text/html, inline)]
This bug report was last modified 4 years and 217 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.