diff options
| author | Elías Gabriel Pérez | 2025-10-25 10:46:56 -0600 |
|---|---|---|
| committer | Juri Linkov | 2025-11-06 09:41:12 +0200 |
| commit | cc589d70039af48332699428cbce352fe890eb2c (patch) | |
| tree | 0231d6ac62e6ca1eaf4e6409720a7a49cf3bba01 /lisp/progmodes/python.el | |
| parent | 2c41bfabbcf9972f32844d53ba6ddf99c3be47a5 (diff) | |
| download | emacs-cc589d70039af48332699428cbce352fe890eb2c.tar.gz emacs-cc589d70039af48332699428cbce352fe890eb2c.zip | |
hideshow: Rework previous changes
* doc/emacs/programs.texi (Hideshow):
* etc/NEWS: Fix doc.
* lisp/progmodes/hideshow.el: Update Commentary Header.
(hs-modes-alist): Remove.
(hs--get-mode-value, hs-grok-mode-type): Rework.
* lisp/treesit.el (treesit-major-mode-setup):
* lisp/emacs-lisp/lisp-mode.el:
* lisp/nxml/nxml-mode.el:
* lisp/progmodes/cc-mode.el:
* lisp/progmodes/f90.el:
* lisp/progmodes/fortran.el:
* lisp/progmodes/hideshow.el:
* lisp/progmodes/icon.el:
* lisp/progmodes/js.el:
* lisp/progmodes/lua-mode.el:
* lisp/progmodes/python.el:
* lisp/progmodes/verilog-mode.el:
* lisp/progmodes/vhdl-mode.el:
* lisp/textmodes/bibtex.el:
* lisp/textmodes/mhtml-mode.el:
* lisp/textmodes/sgml-mode.el:
* lisp/treesit.el: Fix and rework previous changes.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f73a0128b5c..f34fb28826f 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -7355,24 +7355,15 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 7355 | #'python-eldoc-function)))) | 7355 | #'python-eldoc-function)))) |
| 7356 | (eldoc-add-command-completions "python-indent-dedent-line-backspace") | 7356 | (eldoc-add-command-completions "python-indent-dedent-line-backspace") |
| 7357 | 7357 | ||
| 7358 | (add-to-list | 7358 | (setq-local hs-block-start-regexp python-nav-beginning-of-block-regexp) |
| 7359 | 'hs-modes-alist | 7359 | ;; Use the empty string as end regexp so it doesn't default to |
| 7360 | `(python-mode | 7360 | ;; "\\s)". This way parens at end of defun are properly hidden. |
| 7361 | (start . ,python-nav-beginning-of-block-regexp) | 7361 | (setq-local hs-block-end-regexp "") |
| 7362 | ;; Use the empty string as end regexp so it doesn't default to | 7362 | (setq-local hs-c-start-regexp "#") |
| 7363 | ;; "\\s)". This way parens at end of defun are properly hidden. | 7363 | (setq-local hs-forward-sexp-func #'python-hideshow-forward-sexp-function) |
| 7364 | (end . "") | 7364 | (setq-local hs-find-block-beginning-func #'python-nav-beginning-of-block) |
| 7365 | (c-start . "#") | 7365 | (setq-local hs-find-next-block-func #'python-hideshow-find-next-block) |
| 7366 | (forward-fn . python-hideshow-forward-sexp-function) | 7366 | (setq-local hs-looking-at-block-start-p-func #'python-info-looking-at-beginning-of-block) |
| 7367 | (find-beg-fn . python-nav-beginning-of-block) | ||
| 7368 | (find-next-fn . python-hideshow-find-next-block) | ||
| 7369 | (look-start-fn . python-info-looking-at-beginning-of-block))) | ||
| 7370 | |||
| 7371 | (add-to-list | ||
| 7372 | 'hs-modes-alist | ||
| 7373 | '(python-ts-mode | ||
| 7374 | (treesit-things . (or defun sexp)) | ||
| 7375 | (adjust-end-fn . python-ts-hs-adjust-block-end-fn))) | ||
| 7376 | 7367 | ||
| 7377 | (setq-local outline-regexp (python-rx (* space) block-start)) | 7368 | (setq-local outline-regexp (python-rx (* space) block-start)) |
| 7378 | (setq-local outline-level | 7369 | (setq-local outline-level |
| @@ -7446,6 +7437,9 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 7446 | (setq-local forward-sexp-function #'treesit-forward-sexp | 7437 | (setq-local forward-sexp-function #'treesit-forward-sexp |
| 7447 | treesit-sexp-thing 'sexp) | 7438 | treesit-sexp-thing 'sexp) |
| 7448 | 7439 | ||
| 7440 | (setq-local hs-treesit-things '(or defun sexp)) | ||
| 7441 | (setq-local hs-adjust-block-end #'python-ts-hs-adjust-block-end-fn) | ||
| 7442 | |||
| 7449 | (setq-local syntax-propertize-function #'python--treesit-syntax-propertize) | 7443 | (setq-local syntax-propertize-function #'python--treesit-syntax-propertize) |
| 7450 | 7444 | ||
| 7451 | (python-skeleton-add-menu-items) | 7445 | (python-skeleton-add-menu-items) |