1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-19 12:30:47 -07:00

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.
This commit is contained in:
Fabián Ezequiel Gallina 2015-02-07 16:43:47 -03:00
parent 86c50b9af1
commit 2d467a0ff0
4 changed files with 193 additions and 50 deletions

View file

@ -3957,6 +3957,17 @@ Interactively, prompt for symbol."
nil nil symbol))))
(message (python-eldoc--get-doc-at-point symbol)))
;;; Hideshow
(defun python-hideshow-forward-sexp-function (arg)
"Python specific `forward-sexp' function for `hs-minor-mode'.
Argument ARG is ignored."
arg ; Shut up, byte compiler.
(python-nav-end-of-defun)
(unless (python-info-current-line-empty-p)
(backward-char)))
;;; Imenu
@ -4693,11 +4704,16 @@ Arguments START and END narrow the buffer region to work on."
(add-function :before-until (local 'eldoc-documentation-function)
#'python-eldoc-function))
(add-to-list 'hs-special-modes-alist
`(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
,(lambda (_arg)
(python-nav-end-of-defun))
nil))
(add-to-list
'hs-special-modes-alist
`(python-mode
"\\s-*\\(?:def\\|class\\)\\>"
;; Use the empty string as end regexp so it doesn't default to
;; "\\s)". This way parens at end of defun are properly hidden.
""
"#"
python-hideshow-forward-sexp-function
nil))
(set (make-local-variable 'outline-regexp)
(python-rx (* space) block-start))