diff options
| author | Lars Ingebrigtsen | 2022-08-17 13:09:21 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-08-17 13:09:39 +0200 |
| commit | 31e32212670f5774a6dbc0debac8854fa01d8f92 (patch) | |
| tree | cc16e9537bbf15c61924ee9529a0fed94a523a85 /lisp/progmodes/python.el | |
| parent | a631067fba54e873122d40106fec4dacd8eba8db (diff) | |
| download | emacs-31e32212670f5774a6dbc0debac8854fa01d8f92.tar.gz emacs-31e32212670f5774a6dbc0debac8854fa01d8f92.zip | |
Revert "Add Python blocks support for hideshow"
This reverts commit af4cfb519415ed3c1d6d036aac908e4f9ee383eb.
This led to test failures.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 59 |
1 files changed, 6 insertions, 53 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index afcfe1af53d..44df3186b27 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1504,10 +1504,6 @@ marks the next defun after the ones already marked." | |||
| 1504 | The name of the defun should be grouped so it can be retrieved | 1504 | The name of the defun should be grouped so it can be retrieved |
| 1505 | via `match-string'.") | 1505 | via `match-string'.") |
| 1506 | 1506 | ||
| 1507 | (defvar python-nav-beginning-of-block-regexp | ||
| 1508 | (python-rx line-start (* space) block-start) | ||
| 1509 | "Regexp matching block start.") | ||
| 1510 | |||
| 1511 | (defun python-nav--beginning-of-defun (&optional arg) | 1507 | (defun python-nav--beginning-of-defun (&optional arg) |
| 1512 | "Internal implementation of `python-nav-beginning-of-defun'. | 1508 | "Internal implementation of `python-nav-beginning-of-defun'. |
| 1513 | With positive ARG search backwards, else search forwards." | 1509 | With positive ARG search backwards, else search forwards." |
| @@ -4891,36 +4887,9 @@ Interactively, prompt for symbol." | |||
| 4891 | (defun python-hideshow-forward-sexp-function (_arg) | 4887 | (defun python-hideshow-forward-sexp-function (_arg) |
| 4892 | "Python specific `forward-sexp' function for `hs-minor-mode'. | 4888 | "Python specific `forward-sexp' function for `hs-minor-mode'. |
| 4893 | Argument ARG is ignored." | 4889 | Argument ARG is ignored." |
| 4894 | (python-nav-end-of-block)) | 4890 | (python-nav-end-of-defun) |
| 4895 | 4891 | (unless (python-info-current-line-empty-p) | |
| 4896 | (defun python-hideshow-find-next-block (regexp maxp comments) | 4892 | (backward-char))) |
| 4897 | "Python specific `hs-find-next-block' function for `hs-minor-mode'. | ||
| 4898 | Call `python-nav-forward-block' to find next block and check if | ||
| 4899 | block-start ends within MAXP. If COMMENTS is not nil, comments | ||
| 4900 | are also searched. REGEXP is passed to `looking-at' to set | ||
| 4901 | `match-data'." | ||
| 4902 | (let* ((next-block | ||
| 4903 | (save-excursion | ||
| 4904 | (or (and | ||
| 4905 | (python-info-looking-at-beginning-of-block) | ||
| 4906 | (re-search-forward (python-rx block-start) maxp t)) | ||
| 4907 | (and (python-nav-forward-block) | ||
| 4908 | (< (point) maxp) | ||
| 4909 | (re-search-forward (python-rx block-start) maxp t)) | ||
| 4910 | (1+ maxp)))) | ||
| 4911 | (next-comment | ||
| 4912 | (or (when comments | ||
| 4913 | (save-excursion | ||
| 4914 | (cl-loop while (re-search-forward "#" maxp t) | ||
| 4915 | if (python-syntax-context 'comment) | ||
| 4916 | return (point)))) | ||
| 4917 | (1+ maxp))) | ||
| 4918 | (next-block-or-comment (min next-block next-comment))) | ||
| 4919 | (when (<= next-block-or-comment maxp) | ||
| 4920 | (goto-char next-block-or-comment) | ||
| 4921 | (save-excursion | ||
| 4922 | (beginning-of-line) | ||
| 4923 | (looking-at regexp))))) | ||
| 4924 | 4893 | ||
| 4925 | 4894 | ||
| 4926 | ;;; Imenu | 4895 | ;;; Imenu |
| @@ -5417,19 +5386,6 @@ instead of the current physical line." | |||
| 5417 | (beginning-of-line 1) | 5386 | (beginning-of-line 1) |
| 5418 | (looking-at python-nav-beginning-of-defun-regexp)))) | 5387 | (looking-at python-nav-beginning-of-defun-regexp)))) |
| 5419 | 5388 | ||
| 5420 | (defun python-info-looking-at-beginning-of-block () | ||
| 5421 | "Check if point is at the beginning of block." | ||
| 5422 | (let* ((line-beg-pos (line-beginning-position)) | ||
| 5423 | (line-content-start (+ line-beg-pos (current-indentation))) | ||
| 5424 | (block-beg-pos (save-excursion | ||
| 5425 | (python-nav-beginning-of-block)))) | ||
| 5426 | (and block-beg-pos | ||
| 5427 | (= block-beg-pos line-content-start) | ||
| 5428 | (<= (point) line-content-start) | ||
| 5429 | (save-excursion | ||
| 5430 | (beginning-of-line) | ||
| 5431 | (looking-at python-nav-beginning-of-block-regexp))))) | ||
| 5432 | |||
| 5433 | (defun python-info-current-line-comment-p () | 5389 | (defun python-info-current-line-comment-p () |
| 5434 | "Return non-nil if current line is a comment line." | 5390 | "Return non-nil if current line is a comment line." |
| 5435 | (char-equal | 5391 | (char-equal |
| @@ -5879,17 +5835,14 @@ REPORT-FN is Flymake's callback function." | |||
| 5879 | 5835 | ||
| 5880 | (add-to-list | 5836 | (add-to-list |
| 5881 | 'hs-special-modes-alist | 5837 | 'hs-special-modes-alist |
| 5882 | `(python-mode | 5838 | '(python-mode |
| 5883 | ,python-nav-beginning-of-block-regexp | 5839 | "\\s-*\\_<\\(?:def\\|class\\)\\_>" |
| 5884 | ;; Use the empty string as end regexp so it doesn't default to | 5840 | ;; Use the empty string as end regexp so it doesn't default to |
| 5885 | ;; "\\s)". This way parens at end of defun are properly hidden. | 5841 | ;; "\\s)". This way parens at end of defun are properly hidden. |
| 5886 | "" | 5842 | "" |
| 5887 | "#" | 5843 | "#" |
| 5888 | python-hideshow-forward-sexp-function | 5844 | python-hideshow-forward-sexp-function |
| 5889 | nil | 5845 | nil)) |
| 5890 | python-nav-beginning-of-block | ||
| 5891 | python-hideshow-find-next-block | ||
| 5892 | python-info-looking-at-beginning-of-block)) | ||
| 5893 | 5846 | ||
| 5894 | (setq-local outline-regexp (python-rx (* space) block-start)) | 5847 | (setq-local outline-regexp (python-rx (* space) block-start)) |
| 5895 | (setq-local outline-heading-end-regexp ":[^\n]*\n") | 5848 | (setq-local outline-heading-end-regexp ":[^\n]*\n") |