diff options
| author | Fabián Ezequiel Gallina | 2015-02-07 16:43:47 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2015-02-07 16:43:47 -0300 |
| commit | 2d467a0ff0cd446ec0d83044a0be819cbf874cdf (patch) | |
| tree | f719433f1e65da7a6a70f4bd3f1d9231eb626f9d /lisp/progmodes/python.el | |
| parent | 86c50b9af1e68ca87bfc9e6d0cdb28ae2e53cc32 (diff) | |
| download | emacs-2d467a0ff0cd446ec0d83044a0be819cbf874cdf.tar.gz emacs-2d467a0ff0cd446ec0d83044a0be819cbf874cdf.zip | |
Fix hideshow integration.
Fixes: debbugs:19761
* lisp/progmodes/python.el
(python-hideshow-forward-sexp-function): New function based on
Carlos Pita <carlosjosepita@gmail.com> patch.
(python-mode): Make `hs-special-modes-alist` use it and initialize
the end regexp with the empty string to avoid skipping parens.
* test/automated/python-tests.el
(python-tests-visible-string): New function.
(python-parens-electric-indent-1)
(python-triple-quote-pairing): Fix indentation, move require calls.
(python-hideshow-hide-levels-1)
(python-hideshow-hide-levels-2): New tests.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index de251181c14..3399429538f 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -3958,6 +3958,17 @@ Interactively, prompt for symbol." | |||
| 3958 | (message (python-eldoc--get-doc-at-point symbol))) | 3958 | (message (python-eldoc--get-doc-at-point symbol))) |
| 3959 | 3959 | ||
| 3960 | 3960 | ||
| 3961 | ;;; Hideshow | ||
| 3962 | |||
| 3963 | (defun python-hideshow-forward-sexp-function (arg) | ||
| 3964 | "Python specific `forward-sexp' function for `hs-minor-mode'. | ||
| 3965 | Argument ARG is ignored." | ||
| 3966 | arg ; Shut up, byte compiler. | ||
| 3967 | (python-nav-end-of-defun) | ||
| 3968 | (unless (python-info-current-line-empty-p) | ||
| 3969 | (backward-char))) | ||
| 3970 | |||
| 3971 | |||
| 3961 | ;;; Imenu | 3972 | ;;; Imenu |
| 3962 | 3973 | ||
| 3963 | (defvar python-imenu-format-item-label-function | 3974 | (defvar python-imenu-format-item-label-function |
| @@ -4693,11 +4704,16 @@ Arguments START and END narrow the buffer region to work on." | |||
| 4693 | (add-function :before-until (local 'eldoc-documentation-function) | 4704 | (add-function :before-until (local 'eldoc-documentation-function) |
| 4694 | #'python-eldoc-function)) | 4705 | #'python-eldoc-function)) |
| 4695 | 4706 | ||
| 4696 | (add-to-list 'hs-special-modes-alist | 4707 | (add-to-list |
| 4697 | `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" | 4708 | 'hs-special-modes-alist |
| 4698 | ,(lambda (_arg) | 4709 | `(python-mode |
| 4699 | (python-nav-end-of-defun)) | 4710 | "\\s-*\\(?:def\\|class\\)\\>" |
| 4700 | nil)) | 4711 | ;; Use the empty string as end regexp so it doesn't default to |
| 4712 | ;; "\\s)". This way parens at end of defun are properly hidden. | ||
| 4713 | "" | ||
| 4714 | "#" | ||
| 4715 | python-hideshow-forward-sexp-function | ||
| 4716 | nil)) | ||
| 4701 | 4717 | ||
| 4702 | (set (make-local-variable 'outline-regexp) | 4718 | (set (make-local-variable 'outline-regexp) |
| 4703 | (python-rx (* space) block-start)) | 4719 | (python-rx (* space) block-start)) |