ENB: What to do about show-file-line?

15 views
Skip to first unread message

Edward K. Ream

unread,
Aug 5, 2023, 6:46:11 AM8/5/23
to leo-editor

This Engineering Notebook post considers what to do about Leo's show-file-line command, the evil twin of goto-global-line. 


The goto-global-line command is solid, frequently used, and essential. Leo uses its code whenever you click an error link.


In contrast, show-file-line is buggy and seldom used. No other part of Leo uses its code.


The bug


The show-file-line command reports incorrect line numbers for any lines following @others or a section reference (within a node). Apparently, the OP of #3447 was not aware of this bug. Neither was I until yesterday.


There is no good way to fix this bug! Details omitted.


This problem does not apply to goto-global-line. That command knows the target line number. But computing the target line number is much more difficult.


The least bad option


Here are my options:


1. Do nothing except document the bug in the command's docstring.


2. Remove the command. I could make the command invisible by commenting out this line:

   @cmd('goto-global-line')


3. Remove the command by moving its code to the attic.


Summary


Fixing the show-file-line command is not an option. Not now. Not ever.


Removing the command would simplify leoJS, but this option seems too extreme.


The only remaining option is to document the command's defects in its docstring. That's what I'll do.


Edward

Edward K. Ream

unread,
Aug 5, 2023, 6:57:38 AM8/5/23
to leo-editor
On Saturday, August 5, 2023 at 5:46:11 AM UTC-5 Edward K. Ream wrote:

This Engineering Notebook post considers what to do about Leo's show-file-line command, the evil twin of goto-global-line.


I forgot to mention the history of show-file-line.

Years ago, someone suggested showing the file's line number in the status area. This suggestion would not be wise even if show-file-line were bug-free.

Both show-file-line and goto-global-line are memory hogs. They create strings containing the entire contents of the external file. Leo can live with the expense of goto-global-line because it isn't called often. But calling show-file-line every time the selected line changes would be ruinous.

Edward
Reply all
Reply to author
Forward
0 new messages