Subject: bug#78436: Koutliner M-x hyperbole k o vs C-h h k o error messaging

From: Mats Lidell <[email-masked]>
Date: Thu, 15 May 2025 10:32:25 +0200

> Cena Mayo writes:
> This is another instance where I'm just doing it wrong, but noting as a possible  ...I don't know what the right word is - usability issue, maybe? UX? 
> Something along those lines.
>
> Using:  GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin23.6.0, NS appkit-2487.70 Version 14.7.5 (Build 23H527)) of 2025-05-13
>
> GNU Hyperbole 9.0.2pre (downloaded today)
> ====
>
> In this case, attempting to perform Koutliner actions while the *scratch* buffer is active:
>
> a) M-x hyperbole, k, o => 
>
> Debugger entered--Lisp error: (error "(kotl-mode:is-p): ’*scratch*’ is not a valid Hyperbole koutline")
>         error("(kotl-mode:is-p): '*scratch*' is not a valid Hyperbole koutline")
>         hypb:error("(kotl-mode:is-p): '%s' is not a valid Hyperbole koutline" #<buffer *scratch*>)
>         kotl-mode:is-p()
>         kotl-mode:show-all()
>         kotl-mode:overview(nil)
>         funcall-interactively(kotl-mode:overview nil)
>         hui:menu-act(hyperbole nil nil nil)
>         hyperbole(nil nil nil nil)
>         funcall-interactively(hyperbole nil nil nil nil)
>         command-execute(hyperbole record)
>         execute-extended-command(nil "hyperbole" "hyperbole")
>         funcall-interactively(execute-extended-command nil "hyperbole" "hyperbole")
>         command-execute(execute-extended-command)
>
> However, 
>
> b) C-h h, k, o => 
> reports  "hypb:error: (kotl-mode:is-p): ’*scratch*’ is not a valid Hyperbole koutline" in echo. 
>
> At the point I got these messages I was following along with the Info manual (2.1 Invocation) and just randomly selected K , O to see what it did.    I
> hadn't yet read the bit about o(vervw) "Show[ing] first line of each cell", (9.1 Koutliner Menu Commands) so fair enough,  I tried to perform an illegal
> action (attempted that action in a non-Koutliner buffer).  
>
> Further confusion was had when I ran the commands in a .kotl buffer and it (appropriately, although I didn't realize it at the time) showed me the first line
> of each cell.   I assumed most of my existing text had been deleted, so I tried a C-/ to undo. 
>
> That sent a rather inscrutable "Changes to be undone are outside visible portion of buffer" message.   That error seems to be caused by attempting to
> undo a narrowed region.  Which, unbeknownst to me, was turned on.  (Clear as day, there was 'Narrow' in my mode-line.) So I followed the advice in the
> linked thread and invoked M-x widen.
>
> Great, everything returned!  (I eventually figured out that C-h h k a would do it too).   But M-x widen also inserted this at the bottom of my .kotl buffer:
>
> "ben" ;; kvspec:current
> 1 ;; id-counter
> alpha ;; label-type
> 4 ;; label-min-width
> ". " ;; label-separator
> 3 ;; level-indent
>
> ;; depth-first kcell attributes
> [[0
>   (creator "cena@byzantium" create-time "20250514:19:33:49" id-counter 1)]
>  [1
>   (creator "cena@byzantium" create-time "20250514:19:33:49")]]
>
> (C-h h k a did not insert the above).  
>
> I ASSume it's something to do with the cell properties, but I didn't make any changes there - this is all from a fresh install and just typing in a .kotl file
> using whatever the default settings are, then running commands.
>
> Best,
> Cena Mayo

Thanks for the report and for trying out koutliner.

As you figured out the overview action is only valid for a kotline. Hence there is an error message when that is applied to another type of buffer. I suppose what this is telling us is that a more user friendly message could be displayed in this case.

For the narrowing issue. A koutline is not a text format but a binary format. Narrowing is used to hide parts of the buffer that is not meant for the user to edit directly. And if you do edit that the koutline might be broken. Se be careful. The take away is that we need to see if we can turn the error message into something that makes more sense for a koutline user.

Again, thanks for the report.

%% Mats