zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
2.6k stars 184 forks source link

python: special %prog and %default #840

Closed lifenjoiner closed 4 weeks ago

lifenjoiner commented 4 weeks ago

Notepad4 (64-bit) 24.07 r5332 (57527b21)

Snippets:

# %prog and %default: https://docs.python.org/3/library/optparse.html
from optparse import OptionParser

usage = "usage: %prog [options] arg1 arg2"
parser = OptionParser(usage=usage)
parser.add_option("-m", "--mode",
                  default="intermediate",
                  help="interaction mode: novice, intermediate, "
                       "or expert [default: %default]")
parser.parse_args()
print(usage)

Screenshot: optparse

Should be one piece, or they seems weird.

zufuliu commented 4 weeks ago

highlighted as printf-like format specifier.

zufuliu commented 4 weeks ago

Seems not worth to fix, as optparse is deprecated since Python 3.2. image

lifenjoiner commented 4 weeks ago

We always have to read other people's code.

$>rg -c ^%prog python-x64_v3.12.5\Lib
python-x64_v3.12.5\Lib\optparse.py:5
python-x64_v3.12.5\Lib\uu.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\check.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\wheel.py:5
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\uninstall.py:2
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\cache.py:5
python-x64_v3.12.5\Lib\site-packages\pip\_internal\cli\main_parser.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\show.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\hash.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\search.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\debug.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\freeze.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\list.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\configuration.py:6
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\download.py:5
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\index.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\inspect.py:1
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\install.py:5
python-x64_v3.12.5\Lib\site-packages\pip\_internal\commands\help.py:1
zufuliu commented 4 weeks ago

Fixed by 29304ce1c1b3879435bddf07bf45875d5e9aab5e, highlighted similar to %(prog)s and %(default)s (format specifier + placeholder). image