1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

hideshow: Deep cleaning. (Bug#79934)

This is just a refactoring change, simplifying most of the code
and commentaries and removing/deprecating redundant code.

* etc/NEWS: Announce changes.
* lisp/progmodes/hideshow.el (hs-hide-hook, hs-show-hook): Use
'defcustom' instead of 'defvar'.
(hs-block-end-regexp, hs-forward-sexp-function)
(hs-adjust-block-beginning-function)
(hs-adjust-block-end-function, hs-find-block-beginning-function)
(hs-find-next-block-function)
(hs-looking-at-block-start-predicate)
(hs-inside-comment-predicate): Update docstring.
(hs-discard-overlays): Simplify.
(hs-life-goes-on): Update docstring.
(hs-hideable-region-p): Revert previous changes.
(hs-overlay-at): Simplify.
(hs-make-overlay): Fix performance.
(hs-block-positions): Rework.
(hs--add-indicators): Fix performance.
(hs-isearch-show-temporary): Simplify.
(hs-looking-at-block-start-p): Rename ...
(hs-looking-at-block-start-p--default): ... to this.
(hs-forward-sexp, hs-hide-comment-region): Mark as obsolete.
(hs-hide-block-at-point): Rework.
(hs-get-first-block): Rename ...
(hs-get-first-block-on-line): ... to this.
(hs-inside-comment-p--default): Rework.
(hs-find-block-beginning): Rename ...
(hs-find-block-beg-fn--default): ... to this.
(hs-find-next-block): Rename ...
(hs-find-next-block-fn--default): ... to this.
(hs-hide-level-recursive): Rework.
(hs-find-block-beginning-match): Remove function.
(hs-already-hidden-p): Simplify.
(hs-c-like-adjust-block-beginning): Mark as obsolete.
(hs-hide-all, hs-show-all, hs-hide-block, hs-show-block)
(hs-hide-level, hs-hide-initial-comment-block, hs-cycle):
Simplify.
* test/lisp/progmodes/hideshow-tests.el (hideshow-hide-level-1)
(hideshow-hide-level-2):
* test/lisp/progmodes/python-tests.el
(python-hideshow-hide-levels-3, python-hideshow-hide-levels-4):
* test/lisp/progmodes/hideshow-tests.el (hideshow-hide-level-1)
(hideshow-hide-level-2):
* test/lisp/progmodes/python-tests.el
(python-hideshow-hide-levels-3, python-hideshow-hide-levels-4):
Update tests.
This commit is contained in:
Elías Gabriel Pérez 2025-12-05 18:42:54 -06:00 committed by Juri Linkov
parent 15f9050ce5
commit a582f2bb57
4 changed files with 626 additions and 729 deletions

View file

@ -1113,6 +1113,12 @@ blocks.
*** New command 'hs-toggle-all'.
This command hides or shows all the blocks in the current buffer.
---
*** 'hs-hide-level' no longer hide all the blocks in the current buffer.
If 'hs-hide-level' was not inside a code block it would hide all the
blocks in the buffer like 'hs-hide-all'. Now it should only hide all
the second level blocks.
+++
*** New user option 'hs-display-lines-hidden'.
If this option is non-nil, Hideshow displays the number of hidden lines
@ -1155,7 +1161,7 @@ after cursor position. By default this is set to 'after-bol'.
This user option controls the positions on the headline of hideable blocks
where the 'TAB' key cycles the blocks' visibility.
+++
---
*** The variable 'hs-special-modes-alist' is now obsolete.
Instead of customizing Hideshow for a mode by setting the elements of
'hs-special-modes-alist', such as START, COMMENT-START,

File diff suppressed because it is too large Load diff

View file

@ -246,7 +246,7 @@ sub()
(should (string= (hideshow-tests-visible-string) contents)))))
(ert-deftest hideshow-hide-level-1 ()
"Should hide 1st level blocks."
"Should hide 2st level blocks."
(hideshow-tests-with-temp-buffer
c-mode
"
@ -274,40 +274,6 @@ main(int argc, char **argv)
\"String\"
int
main(int argc, char **argv)
{}
"))))
(ert-deftest hideshow-hide-level-2 ()
"Should hide 2nd level blocks."
(hideshow-tests-with-temp-buffer
c-mode
"
/*
Comments
*/
\"String\"
int
main(int argc, char **argv)
{
if (argc > 1) {
printf(\"Hello\\n\");
}
}
"
(hs-hide-level 2)
(should (string=
(hideshow-tests-visible-string)
"
/*
Comments
*/
\"String\"
int
main(int argc, char **argv)
{

View file

@ -7428,7 +7428,7 @@ class SomeClass:
(or enabled (hs-minor-mode -1)))))
(ert-deftest python-hideshow-hide-levels-3 ()
"Should hide all blocks."
"Should hide 2nd level blocks."
(python-tests-with-temp-buffer
"
def f():
@ -7447,19 +7447,22 @@ def g():
(python-tests-visible-string)
"
def f():
if 0:
def g():
pass
"))))
(ert-deftest python-hideshow-hide-levels-4 ()
"Should hide 2nd level block."
"Should hide 3nd level block."
(python-tests-with-temp-buffer
"
def f():
if 0:
l = [i for i in range(5)
if i < 3]
abc = o.match(1, 2, 3)
if 1:
abc = o.match(1, 2, 3)
def g():
pass
@ -7472,6 +7475,9 @@ def g():
"
def f():
if 0:
l = [i for i in range(5)
if i < 3]
if 1:
def g():
pass