hideshow: Fix 'hs-hide-block-behavior' set to 'after-cursor'.

Bug#80455.

* etc/NEWS: Document changed behavior.

* lisp/progmodes/hideshow.el (hs-get-near-block): Remove
'forward-line'.
(hs-hide-block-behavior): Update docstring.

* doc/emacs/programs.texi (Hideshow): Update.

Suggested-by: Dima Kogan <dima@secretsauce.net>
This commit is contained in:
Elias Gabriel Perez
2026-03-06 17:13:28 -06:00
committed by Eli Zaretskii
parent 687fe594d6
commit 5c961f4903
3 changed files with 16 additions and 13 deletions

View File

@@ -1759,10 +1759,11 @@ If non-@code{nil}, @code{hs-hide-all}, @code{hs-cycle} and
@code{hs-hide-level} hide comments too.
@item hs-hide-block-behavior
This variable controls how @code{hs-hide-block} and
@code{hs-toggle-hiding} should hide a block. The possible values can be
'after-bol', hide the innermost block to which the current line belongs;
or 'after-cursor', hide the block after cursor position.
This variable controls how @code{hs-hide-block}, @code{hs-cycle},
@code{hs-hide-level}, and @code{hs-toggle-hiding} should hide a block.
The possible values can be 'after-bol', hide the innermost block to
which the current line belongs; or 'after-cursor', hide the block after
cursor position.
@item hs-display-lines-hidden
If non-@code{nil}, display the number of hidden lines next to the

View File

@@ -1351,11 +1351,13 @@ to customize the indicators appearance only if 'hs-indicator-type' is
set to 'margin' or nil.
+++
*** New user option 'hs-hide-block-behavior'.
This user option controls how 'hs-hide-block' and 'hs-toggle-hiding'
should hide a block. If set to 'after-bol', hide the innermost block to
which the current line belongs. If set to 'after-cursor', hide the block
after cursor position. By default this is set to 'after-bol'.
*** The hiding behavior of some hideshow commands has changed.
'hs-hide-block', 'hs-hide-level', 'hs-cycle' and 'hs-toggle-hiding' now
hide the innermost block to which the current line belongs instead of
the block after cursor position.
To restore the old behavior set the new user option
'hs-hide-block-behavior' to 'after-cursor'.
+++
*** New user option 'hs-cycle-filter' for visibility-cycling with 'TAB'.

View File

@@ -330,6 +330,7 @@ If non-nil, `hs-hide-all', `hs-cycle' and `hs-hide-level' will hide
comments too."
:type 'boolean)
;; This is only intended for backward compatibility (bug#80455)
(defcustom hs-hide-block-behavior 'after-bol
"How hideshow should hide a block.
If set to `after-bol', hide the innermost block to which the current
@@ -337,8 +338,8 @@ line belongs.
If set to `after-cursor', hide the block after cursor position.
This only has effect in `hs-hide-block' and `hs-toggle-hiding'
commands."
This only has effect in `hs-hide-block', `hs-cycle', `hs-hide-level' and
`hs-toggle-hiding' commands."
:type
'(choice
(const :tag "Hide the block after cursor" after-cursor)
@@ -939,8 +940,7 @@ Intended to be used in commands."
t)
((and (or (hs-hideable-block-p)
(and (forward-line 0)
(funcall hs-find-block-beginning-function)
(and (funcall hs-find-block-beginning-function)
(hs-hideable-block-p))))
t))))