aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | Make tree-sitter fontification automatically updateYuan Fu2022-11-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Now nodes that are affected and changed during re-parse will be correctly refontified. Nodes can change even if it corresponding text wasn't edited: additional text can complete the parse tree and resolve error nodes, for example. * lisp/progmodes/python.el (python-mode): Create Python parser before calling treesit-major-mode-setup. * lisp/treesit.el (treesit--font-lock-notifier): New function. (treesit-major-mode-setup): Register fontifier with every existing parser.
* | Remove the contextual hack in tree-sitter fontificationYuan Fu2022-11-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now have a better facility that can replace the contextual hack. The C part is in the previous commit, and the Lisp part work will be in the next commit. * doc/lispref/modes.texi (Parser-based Font Lock): Update manual. * lisp/progmodes/js.el (js--treesit-font-lock-settings) * lisp/progmodes/python.el (python--treesit-settings) * lisp/progmodes/ts-mode.el (ts-mode--font-lock-settings): Stop marking contextual nodes. * lisp/treesit.el (treesit-font-lock-contextual-post-process): Remove function. (treesit-font-lock-fontify-region): Remove code processing contextual nodes.
* | Utilize new face font-lock-escape-face in python-modeYuan Fu2022-11-101-1/+1
| | | | | | | | | | * lisp/progmodes/python.el (python--treesit-settings): Use font-lock-escape-face rather than font-lock-constant-face.
* | Mimic existing python-mode beg/end-of-defun behavior betterYuan Fu2022-11-091-4/+52
| | | | | | | | | | | | | | * lisp/progmodes/python.el (python-treesit-beginning-of-defun) (python-treesit-end-of-defun): New functions. * lisp/progmodes/python.el (python-mode): Use custom beg/end-of-defun functions.
* | Pass region start and end to tree-sitter fontification functionsYuan Fu2022-11-021-5/+7
| | | | | | | | | | | | | | | | | | | | * doc/lispref/modes.texi (Parser-based Font Lock): Update manual. * lisp/progmodes/js.el (js--fontify-template-string) * lisp/progmodes/python.el (python--treesit-fontify-string): Update function to only fontify within the region. * lisp/treesit.el (treesit-font-lock-rules): Update docstring. (treesit-font-lock-fontify-region): Pass START and END to fontification functions.
* | Add handling of contextual entities in tree-sitter font-lockYuan Fu2022-11-021-8/+2
| | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el: Remove function. (python--treesit-settings): Capture contextual node. * lisp/treesit.el (treesit--set-nonsticky): (treesit-font-lock-contextual-post-process): New functions. (treesit-font-lock-fontify-region): Change local variable START and END to NODE-START and NODE-END, handle special capture name "contextual". * doc/lispref/modes.texi (Parser-based Font Lock): Update manual.
* | Change signature of tree-sitter font-lock functionsYuan Fu2022-11-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change from (START END NODE OVERRIDE &rest _) to (NODE OVERRIDE &rest _) START and END aren't used frequently enough to justify. If a fontification function needs them, it can get them from NODE. * doc/lispref/modes.texi (Parser-based Font Lock): Update manual. * lisp/progmodes/js.el (js--fontify-template-string) * lisp/progmodes/python.el (python--treesit-fontify-string) (python--treesit-fontify-string-end): Change signature. * lisp/treesit.el (treesit-font-lock-rules): Update docstring. (treesit-font-lock-fontify-region): Remove START and END arguments.
* | Fix string fontification for tree-sitter python-modeYuan Fu2022-11-011-6/+10
| | | | | | | | | | | | | | | | | | | | | | Now when user inserts a ending quote, the whole string is ganranteed to be refontified and redisplayed. * lisp/progmodes/python.el (python--treesit-fontify-string): Change docstring, now it's called on the leading quote. (python--treesit-fontify-string-end): New function. (python--treesit-settings): Capture both leading and ending quote in a string.
* | Use treesit-fontify-with-override in tree-sitter functionsYuan Fu2022-10-311-3/+4
| | | | | | | | | | | | * lisp/progmodes/js.el (js--fontify-template-string) * lisp/progmodes/python.el (python--treesit-fontify-string): Use treesit-fontify-with-override.
* | Add an argument OVERRIDE to tree-sitter font-lock functionsYuan Fu2022-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/modes.texi (Parser-based Font Lock): Reflect this change in manual. * lisp/progmodes/js.el (js--fontify-template-string): Add _OVERRIDE argument. * lisp/progmodes/python.el (python--treesit-fontify-string): Add _OVERRIDE argument. * lisp/treesit.el (treesit-font-lock-rules): Update docstring. (treesit-fontify-with-override): New function. (treesit-font-lock-fontify-region): Extract out into treesit-fontify-with-override.
* | Improve python tree-sitter's string fontificationYuan Fu2022-10-311-9/+23
| | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python--treesit-fontify-string): Handle not only f-strings, but also docstrings, and NODE is now the last quote rather than the whole string. (python--treesit-settings): Use python--treesit-fontify-string for every occasion.
* | Separate python tree-sitter fontification into featuresYuan Fu2022-10-291-31/+51
| | | | | | | | | | | | | | | | | | Level 1: comment string function-name class-name Level 2: keyword builtin constant type Level 3: assignment decorator escape-sequence string-interpolation * lisp/progmodes/python.el (python--treesit-settings): Separate. (python-mode): Set features.
* | Add tree-sitter navigation support to python-modeYuan Fu2022-10-261-0/+4
| | | | | | | | | | * lisp/progmodes/python.el (python-mode): Set treesit-defun-type-regexp.
* | New tree-sitter toggle schemeYuan Fu2022-10-251-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This version: central variable, everything controlled by treesit-settings. Major mode sets up tree-sitter/non-tree-sitter in a conditional branch, based on the setting. * lisp/treesit.el (treesit-settings): New option. (treesit-defun-type-regexp): Change docstring. (treesit-mode-supported) (treesit-required-languages) (treesit--local-variable-backup): Remove variables. (treesit--backup-local-variable) (treesit-mode) (global-treesit-mode--turn-on) (global-treesit-mode): Remove functions. (treesit--setting-for-mode): New function. (treesit-ready-p): New argument MODE, changed REPORT to QUIET, and LANGUAGEs to LANGUAGE (now it can be a single symbol or a list of them). (treesit-major-mode-setup): New function. Mostly comes from treesit-mode. * test/src/treesit-tests.el (treesit-misc): New test. * lisp/progmodes/python.el (python-mode): Move some setup code into the conditional branch at the end. * lisp/progmodes/js.el (js-json-mode) (js-mode): Move some setup code into the conditional branch at the end. * lisp/progmodes/ts-mode.el: Move tree-sitter setup into the conditional branch.
* | Revise the toggle scheme of tree-sitter (again)Yuan Fu2022-10-191-40/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now instead of a toggle function (major-mode-backend-function), we let major mode set local variables like treesit-font-lock-settings, treesit-imenu-function, then treesit-mode takes care of activating those things (clearing font-lock-keywords, setting imenu-create-index-function to treesit-imenu-function, etc). js.el and python.el: I've returned js-mode and python-mode to exactly what they were before tree-sitter change, plus lines at the end setting up tree-sitter variables. Sorry about all these fuss :-D * lisp/treesit.el (treesit-mode-inhibit-message): Remove option. (major-mode-backend-function) (treesit-remapped-major-mode-alist): Remove variables. (treesit-mode): Move down to the end of buffer. Do more things. (global-treesit-mode): Move down to the end of buffer. Don't handle major-mode-remap-alist anymore. (global-treesit-mode--turn-on): Move down to the end of buffer. (treesit-ready-p): Move down to the end of buffer. Changed signature. (treesit-font-lock-enable): Remove function. (treesit-defun-type-regexp): New variable. (treesit-beginning-of-defun) (treesit-end-of-defun): New function. (treesit-imenu-function): New variable. (treesit-mode-supported) (treesit-required-languages) (treesit--local-variable-backup): New variables. (treesit--backup-local-variable): New function * lisp/progmodes/js.el (js-use-tree-sitter): Remove option. (js--treesit-defun-type-regexp): Remove variable. (Now set inline in js-mode.) (js--treesit-beginning-of-defun) (js--treesit-end-of-defun): Remove functions. (Now use treesit-beginning/end-of-defun.) (js--backend-toggle) (js--json-backend-toggle): Remove function. (js-mode) (js-json-mode): Restore back to before tree-sitter changes. Add tree-sitter setup at the end. * lisp/progmodes/python.el (python--backend-toggle): Remove function. (python-mode): Restore back to before tree-sitter changes. Add tree-sitter setup at the end. * lisp/progmodes/ts-mode.el (ts-mode--font-lock-settings): Use js--fontify-template-string. (ts-mode--fontify-template-string): Remove function (because we can just use js--fontify-template-string). (ts-mode--defun-type-regexp): Remove variable (now set inline in ts-mode). (ts-mode--beginning-of-defun) (ts-mode--end-of-defun): Remove functions (now using treesit-beginning/end-of-defun). (ts-mode): Setup tree-sitter variables and then turn on treesit-mode or move to js-mode.
* | ; * lisp/progmodes/python.el (python--backend-toggle): Use cond.Yuan Fu2022-10-181-13/+16
| |
* | Install new toggle scheme for tree-sitterYuan Fu2022-10-181-36/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Basically we now have treesit-mode and global-treesit-mode. Major modes set major-mode-backend-function which treesit-mode calls to activate/deactivate tree-sitter. js.el needs a bit explanation: I'm so sorry for messing up the history, but basically now js-mode and js-json-mode should be exactly the same as before any tree-sitter change was introduced, sans some initialization code that are moved to js(-json)--backend-toggle. js-mode and js-json-mode now just sets major-mode-backend-function and initialize with js(-json)--backend-toggle. * lisp/treesit.el (treesit-mode-inhibit-message): New option. (treesit-can-enable-p): Remove function. (major-mode-backend-function) (treesit-remapped-major-mode-alist): New variables. (treesit-mode) (global-treesit-mode): New minor modes. (global-treesit-mode--turn-on) (treesit-ready-p): New functions. * lisp/progmodes/python.el: Remove option. (python--backend-toggle): New function. (python-mode): Remove the if-form, all the initialization code are moved to python--backend-toggle, python-mode now just sets major-mode-backend-function and initialize with python--backend-toggle. * lisp/progmodes/js.el (js--treesit-can-enable-p) (js--json-treesit-can-enable-p) (js--treesit-enable) (js--json-treesit-enable): Remove functions. (js--backend-toggle) (js-json--backend-toggle): New function. * lisp/progmodes/ts-mode.el (ts-mode): Use treesit-ready-p.
* | Rework tree-sitter font-lockYuan Fu2022-10-131-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove :toggle and :level, add :feature. * lisp/progmodes/js.el (js--treesit-settings): Add :feature. (js--treesit-enable): Set treesit-font-lock-feature-list. * lisp/progmodes/python.el: Replace :level with :feature. (python-mode): Set treesit-font-lock-feature-list. * lisp/treesit.el (treesit-font-lock-feature-list): New variable. (treesit-font-lock-settings): Change format. (treesit-font-lock-rules): Remove :toggle and :level, add :feature. (treesit-font-lock-recompute-features): New function. (treesit-font-lock-fontify-region): Change to work with the new format. (treesit-font-lock-enable): Add call to treesit-font-lock-recompute-features. And improve the font-lock-mode workaround.
* | Add :version tag for new tree-sitter custom optionsYuan Fu2022-10-091-1/+2
| | | | | | | | | | | | * lisp/progmodes/python.el (python-use-tree-sitter): Add version tag. * lisp/treesit.el (treesit): (treesit-max-buffer-size): Add version tag.
* | Make python tree-sitter font-lock support decoration levelsYuan Fu2022-10-091-12/+16
| | | | | | | | | | * lisp/progmodes/python.el (python--treesit-settings): Stratify into three levels.
* | Merge branch 'master' into feature/tree-sitterYuan Fu2022-10-051-73/+363
|\ \ | |/
| * Fix syntax check in python-info-looking-at-beginning-of-defunkobarity2022-09-231-5/+5
| | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-info-looking-at-beginning-of-defun): Check syntax after moving to the beginning of line. * test/lisp/progmodes/python-tests.el (python-nav-beginning-of-defun-6) (python-end-of-defun-1, python-info-looking-at-beginning-of-defun-3): New tests (bug#58023).
| * Merge from origin/emacs-28Stefan Kangas2022-09-211-2/+2
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 478b786d5a ; * doc/lispref/windows.texi (Window Hooks): Fix a typo (b... 5085351645 * lisp/text-modes/tex-mode.el (tex-mode): Fix AUCTeX regre... ee6f8598ca Add vc-annotate-switches to manual 616dcf27e5 ; Fix typos in Lisp symbols 5405852541 Remove mention of non-existent `annotate-switches' 191505b8a3 Mention that src/macuvs.h sometimes needs committing 10373c4b68 ; More comment fixes in font.h (bug#57935) c2595b8dcc ; * src/font.h (struct font_driver): Comment fix. 97b928ce09 MacOS ld warning from native compilation (bug#57849)
| | * ; Fix typos in Lisp symbolsStefan Kangas2022-09-201-2/+2
| | |
| | * Fix customization-group of 'python-forward-sexp-function'Eli Zaretskii2022-04-211-0/+2
| | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-forward-sexp-function): Make it be part of both 'python' and 'python-flymake' groups. (Bug#55027) Do not merge to master.
| | * Avoid hangs in python-mode with debug-on-error setLars Ingebrigtsen2022-04-181-17/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-nav-end-of-statement): Avoid using cl-assert here, because this is called from the font-lock machinery, and if debug-on-error is set here, we'll hang Emacs (bug#54996). Do not merge to master.
| * | Remap 'up-list' in python-mode-mapAugusto Stoffel2022-09-181-0/+1
| | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-mode-map): Remap 'up-list' to 'python-nav-up-list' (bug#57885).
| * | Add new command python-shell-restartAugusto Stoffel2022-09-181-0/+20
| | | | | | | | | | | | * lisp/progmodes/python.el (python-shell-restart): New command (bug#57885).
| * | Delete many items obsolete since 24.3Stefan Kangas2022-09-091-34/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/allout.el (allout-exposure-change-hook) (allout-structure-added-hook, allout-structure-deleted-hook) (allout-structure-shifted-hook): * lisp/arc-mode.el (archive-extract-hooks): * lisp/buff-menu.el (Buffer-menu-buffer+size-width): * lisp/calendar/timeclock.el (timeclock-modeline-display) (timeclock-modeline-display, timeclock-update-modeline): * lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym-function-arglist): * lisp/cedet/semantic/db-file.el (semanticdb-save-database-hooks): * lisp/cedet/semantic/edit.el (semantic-change-hooks) (semantic-edits-new-change-hooks) (semantic-edits-delete-change-hooks) (semantic-edits-reparse-change-hooks): * lisp/cedet/semantic/lex.el (semantic-lex-reset-hooks): * lisp/comint.el (comint--unquote&expand-filename) (comint-unquote-filename): * lisp/custom.el (user-variable-p): * lisp/dired.el (dired-shrink-to-fit, dired-pop-to-buffer) (dired-sort-set-modeline): * lisp/ebuff-menu.el (Electric-buffer-menu-mode): * lisp/emacs-lisp/byte-run.el (macro-declaration-function): * lisp/emacs-lisp/checkdoc.el (custom-print-functions) (checkdoc-comment-style-hooks): * lisp/emacs-lisp/cl-lib.el (custom-print-functions): * lisp/emacs-lisp/edebug.el (gud-inhibit-global-bindings): * lisp/erc/erc-dcc.el (erc-dcc-chat-filter-hook): * lisp/eshell/esh-mode.el (eshell-status-in-modeline): * lisp/eshell/eshell.el (eshell-add-to-window-buffer-names) (eshell-remove-from-window-buffer-names): * lisp/faces.el (set-face-underline-p, font-list-limit): * lisp/files.el (automount-dir-prefix, toggle-read-only): * lisp/filesets.el (filesets-cache-fill-content-hooks): * lisp/frame.el (automatic-hscrolling): * lisp/generic-x.el (javascript-generic-mode) (javascript-generic-mode-hook): * lisp/gnus/gnus-start.el (gnus-subscribe-newsgroup-hooks): * lisp/gnus/nndiary.el (nndiary-request-create-group-hooks) (nndiary-request-update-info-hooks) (nndiary-request-accept-article-hooks): * lisp/htmlfontify.el (hfy-post-html-hooks): * lisp/international/mule-cmds.el (inactivate-current-input-method-function) (inactivate-input-method, input-method-inactivate-hook) (ucs-insert): * lisp/international/quail.el (quail-inactivate) (quail-inactivate-hook): * lisp/international/robin.el (robin-inactivate) (robin-inactivate-hook): * lisp/leim/quail/hangul.el (hangul-input-method-inactivate): * lisp/leim/quail/uni-input.el (ucs-input-inactivate): * lisp/mail/emacsbug.el (report-emacs-bug-info): * lisp/mh-e/mh-e.el (mh-kill-folder-suppress-prompt-hooks): * lisp/mpc.el (mpc-string-prefix-p): * lisp/net/rcirc.el (rcirc-print-hooks, rcirc-sentinel-hooks) (rcirc-receive-message-hooks, rcirc-activity-hooks): * lisp/obsolete/crisp.el (crisp-mode-modeline-string): * lisp/pcomplete.el (pcomplete-arg-quote-list) (pcomplete-quote-argument): * lisp/progmodes/cc-mode.el (c-prepare-bug-report-hooks): * lisp/progmodes/python.el (python-info-ppss-context) (python-info-ppss-context-type) (python-info-ppss-comment-or-string-p, python-indent) (python-guess-indent, python-buffer, python-preoutput-result) (python-proc, python-send-receive, python-send-string) (python-use-skeletons): * lisp/progmodes/sh-script.el (sh-maybe-here-document): * lisp/replace.el (query-replace-interactive): * lisp/strokes.el (strokes-modeline-string): * lisp/subr.el (redraw-modeline): * lisp/term.el (term-default-fg-color, term-default-bg-color): * lisp/textmodes/tex-mode.el (latex-string-prefix-p) (tex-string-prefix-p): * lisp/url/url-parse.el (url-recreate-url-attributes): * lisp/vc/add-log.el (change-log-acknowledgement): * lisp/vc/ediff-wind.el (ediff-choose-window-setup-function-automatically): * lisp/vc/pcvs-util.el (cvs-string-prefix-p): * lisp/vc/vc.el (vc-string-prefix-p): * lisp/window.el (display-buffer-function): * lisp/winner.el (winner-mode-leave-hook): Remove many functions and variables obsolete since 24.3. * lisp/buff-menu.el (list-buffers--refresh): * lisp/dired.el (dired-mode-map): * lisp/files.el (abbreviate-file-name): * lisp/generic-x.el (generic-default-modes): * lisp/mh-e/mh-funcs.el (mh-kill-folder): * lisp/progmodes/hideif.el (hide-ifdef-mode-submap): * lisp/replace.el (query-replace-read-from): * lisp/term.el (term): * lisp/window.el (display-buffer): Don't use above deleted functions and variables. * src/marker.c (Fbuffer_has_markers_at): Delete DEFUN obsolete since 24.3. (syms_of_marker) <Sbuffer_has_markers_at>: Delete defsubr. * lisp/subr.el (buffer-has-markers-at): Remove obsoletion of above deleted DEFUN. * etc/TODO: Doc fix; don't mention above deleted function. * admin/cus-test.el (cus-test-get-options): * lisp/pcomplete.el: Doc fixes; don't mention removed items. ; * etc/NEWS: List removed items.
| * | Apply syntax highlighting for all python f-stringsLaurence Warne2022-09-061-3/+14
| | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python--f-string-p) (python--font-lock-f-strings): Edit functions to use a regular expression matching all f-strings (bug#56757).
| * | Add Python import management commandsAugusto Stoffel2022-09-041-5/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-interpreter): New variable (python-mode-map): Keybindings and menu entries for new commands (python--list-imports, python-import-history, python--query-import) (python--do-isort): New variables and helper functions. (python-add-import, python-import-symbol-at-point) (python-remove-import, python-sort-imports, python-fix-imports): New interactive commands (bug#57574).
| * | Python shells dedicated to a projectAugusto Stoffel2022-09-041-24/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el: Require 'seq' and (optionally) 'compat' and 'project' libraries. (python-shell-dedicated): New user option (python-shell-get-process-name): Adapt to project-dedicated shells. (run-python): Offer possibility to create a project-dedicated shell, or use 'python-shell-dedicated' as the default behavior. (python-shell-get-buffer): Adapt to project-dedicated shells (bug#56997).
* | | Add :override flag for python tree-sitter font-lock settingsYuan Fu2022-10-041-0/+1
| | | | | | | | | | | | * lisp/progmodes/python.el (python--treesit-settings): Add :override.
* | | Fix python tree-sitter font-lockYuan Fu2022-10-041-1/+9
| | | | | | | | | | | | | | | | | | | | | Add fontification for lhs attribute and some operators. * lisp/progmodes/python.el (python--treesit-keywords): Add operators. (python--treesit-settings): Add lhs attribute.
* | | ; * lisp/progmodes/python.el (python-mode): Fix typo.Yuan Fu2022-09-241-1/+1
| | |
* | | Update and enable treesit-imenu function in python.elYuan Fu2022-09-241-45/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python--treesit-settings): Add docstring. (python--imenu-treesit-create-index-1): Rewrite with treesit-induce-sparse-tree. (python-imenu-treesit-create-index): Move main body to python--imenu-treesit-create-index-1. (python-imenu-treesit-create-flat-index): Fix typo. (python-mode): Enable treesit-imenu. Also fix indentation for which-func code.
* | | Utilize tree-sitter in python.elYuan Fu2022-09-221-4/+242
|/ / | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-use-tree-sitter): New option. (python--treesit-keywords, python--treesit-builtins) (python--treesit-constants, python--treesit-operators) (python--treesit-special-attributes, python--treesit-exceptions): New variables. (python--treesit-fontify-string, python--treesit-settings) (python--imenu-treesit-create-index) (python--imenu-treesit-create-flat-index) (python-info-treesit-current-defun): New functions. (python-mode): Enable tree-sitter font-lock and which-func.
* | Add Python blocks support for hideshowkobarity2022-08-251-6/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-nav-beginning-of-block-regexp): New variable. (python-hideshow-forward-sexp-function): Change to call `python-nav-end-of-block'. (python-hideshow-find-next-block): New function to be used as FIND-NEXT-BLOCK-FUNC in `hs-special-modes-alist'. (python-info-looking-at-beginning-of-block): New function to be used as LOOKING-AT-BLOCK-START-P-FUNC in `hs-special-modes-alist'. (python-mode): Change settings of `hs-special-modes-alist'. * test/lisp/progmodes/python-tests.el (python-hideshow-hide-levels-1): Fix to keep empty lines. (python-info-looking-at-beginning-of-block-1) (python-hideshow-hide-levels-3, python-hideshow-hide-levels-4) (python-hideshow-hide-all-1, python-hideshow-hide-all-2) (python-hideshow-hide-all-3, python-hideshow-hide-block-1): New tests (bug#56635).
* | Fix completion-predicate of Python shell commandsAugusto Stoffel2022-08-231-1/+9
| | | | | | | | | | | | * lisp/progmodes/python.el: Change some completion predicates. (python-shell--completion-predicate): New completion predicate function. (Bug#57184)
* | python.el: Add completion-predicate symbol property to commandsAugusto Stoffel2022-08-191-7/+61
| | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el: Add a completion-predicate property to most commands defined in this file; some are only useful in python-mode, others in inferior-python mode as well. (Bug#53913) (python-skeleton-define, python-define-auxiliary-skeleton): Add appropriate completion-predicate properties. (python--completion-predicate): New function.
* | python-mode: Remove special outline-heading-end-regexpAugusto Stoffel2022-08-191-1/+0
| | | | | | | | | | | | | | | | It doesn't work well with the new type annotation syntax introduced in Python 3.5. * lisp/progmodes/python.el (python-mode): Remove buffer-local setting of outline-heading-end-regexp. (Bug#53913)
* | python.el: Adjustments to Flymake backendAugusto Stoffel2022-08-191-5/+9
| | | | | | | | | | | | | | * lisp/progmodes/python (python-flymake-command): Advertise possiblity to use pylint. (python-flymake-command-output-pattern): Make compatible with recent versions of pyflakes. (Bug#53913)
* | python-check-command: Don't use absolute file namesAugusto Stoffel2022-08-191-4/+5
| | | | | | | | | | | | | | | | Absolute executable file names are incompatible with Tramp and packages that switch between virtualenvs. * lisp/progmodes/python.el (python-check-command): Don't use absolute file names. (Bug#53913)
* | Fix Python indentation of block continuationkobarity2022-08-181-1/+7
| | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-indent--calculate-indentation): Fix indentation of :after-backslash-block-continuation. * test/lisp/progmodes/python-tests.el (python-indent-after-backslash-6): New test (bug#57262).
* | Enhance Python font-lock to support multilineskobarity2022-08-171-16/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/lisp/progmodes/python-tests.el (python-tests-assert-faces-after-change): New helper function. (python-font-lock-keywords-level-1-3) (python-font-lock-assignment-statement-multiline-*): New tests. * lisp/progmodes/python.el (python-rx): Add `sp-nl' to represent space or newline (with/without backslash). (python-font-lock-keywords-level-1) (python-font-lock-keywords-maximum-decoration): Allow newlines where appropriate. (python-font-lock-extend-region): New function. (python-mode): Set `python-font-lock-extend-region' to `font-lock-extend-after-change-region-function'.
* | Revert "Add Python blocks support for hideshow"Lars Ingebrigtsen2022-08-171-53/+6
| | | | | | | | | | | | This reverts commit af4cfb519415ed3c1d6d036aac908e4f9ee383eb. This led to test failures.
* | Add Python blocks support for hideshowkobarity2022-08-171-6/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python-nav-beginning-of-block-regexp): New variable. (python-hideshow-forward-sexp-function): Change to call `python-nav-end-of-block'. (python-hideshow-find-next-block): New function to be used as FIND-NEXT-BLOCK-FUNC in `hs-special-modes-alist'. (python-info-looking-at-beginning-of-block): New function to be used as LOOKING-AT-BLOCK-START-P-FUNC in `hs-special-modes-alist'. (python-mode): Change settings of `hs-special-modes-alist'. * test/lisp/progmodes/python-tests.el (python-hideshow-hide-levels-1): Fix to keep empty lines. (python-info-looking-at-beginning-of-block-1) (python-hideshow-hide-levels-3, python-hideshow-hide-levels-4) (python-hideshow-hide-all-1, python-hideshow-hide-all-2) (python-hideshow-hide-all-3, python-hideshow-hide-block-1): New tests (bug#56635).
* | Fix `python-nav-forward-block' moving backward under certain conditionskobarity2022-08-151-2/+4
| | | | | | | | | | * lisp/progmodes/python.el (python-nav-forward-block): Add check for not moving backward (bug#57223).
* | Fix python escape code fontification for multi-line literalsLaurence Warne2022-08-091-7/+15
| | | | | | | | | | | | | | | | | | | | * lisp/progmodes/python.el (python--string-bytes-literal-matcher): Go backward one char after a match so that consecutive escape codes are highlighted (python--not-raw-string-literal-start-regexp): Make regular expression more comprehensive, so multi-line bytes literals are not caught (python-rx): Accept one to three octal digits in octal escape codes instead of always three
* | Clean up some local variable sectionsStefan Kangas2022-08-081-5/+0
| | | | | | | | | | | | | | | | | | | | * lisp/filesets.el: * lisp/mh-e/mh-*.el: * lisp/progmodes/python.el (python): Don't set options that are already set in .dir-locals.el. * lisp/textmodes/ispell.el: Remove redundant local variables. * lisp/gnus/nnmaildir.el: Remove local variables that conflicts with Emacs defaults.