Subject: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command for outline

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 17 Oct 2020 08:36:47 +0200

Yuan Fu <[email-masked]> writes:

> This patch should make outline behaves like org: S-TAB always cycle
> the whole buffer, regardless where is the point. TAB cycles a heading,
> and does nothing if point is before the first heading.

I think the behaviour makes sense, but the implementation isn't ideal:

[...]

> +  (condition-case nil
> +      (pcase (outline--cycle-state)
> +        ('hide-all
> +         (if (outline-has-subheading-p)
> +             (progn (outline-show-children)
> +                    (message "Only headings"))
> +           (outline-show-subtree)
> +           (message "Show all")))
> +        ('headings-only
> +         (outline-show-subtree)
> +         (message "Show all"))
> +        ('show-all
> +         (outline-hide-subtree)
> +         (message "Hide all")))
> +    ;; If error: "Before first heading" occurs, ignore it.
> +    (error nil)))

This is basically an `ignore-errors' around a whole bunch of code, used
as a program flow mechanism, and that's always awkward, because it hides
real errors in the code.

Altering the functions to not error out in these situations would be
better.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no