Request for slight tweak when editing new headlines

33 views
Skip to first unread message

jkn

unread,
Apr 22, 2021, 6:27:23 AM4/22/21
to leo-editor

Hi Edward
    this is pretty small beer, but I thought I'd mention it.

I often want to have a node headline comprising the date/time. I actually have a keyboard shortcut for 'insert-headline-time'.

When you create a node, it starts off being called 'newHeadline', with that text preselected (BG color blue in my case). So if you start typing a new headline name, the 'newHeadline' is deleted and just your replacement headline remains.

However, if I do this:

    - create new node ('newHeadline' preselected)
    - KB shortcut for 'insert-headline-time'

Then the 'newHeadline' gets *de*selected before the 'insert-headline-time' is performed. The end result is that I get both as the headline:

    newHeadlineThu22Apr2021 11:23

and have to delete the first part. Same thing happens if I do the 'insert-headline-time' via the minibuffer.

Any chance of addressing this? As I say, it's only a small scratch...

Thanks a lot for Leo
    Jon N

Edward K. Ream

unread,
Apr 22, 2021, 7:04:24 AM4/22/21
to leo-editor
On Thu, Apr 22, 2021 at 5:27 AM jkn <jkn...@nicorp.f9.co.uk> wrote:

Any chance of addressing this? As I say, it's only a small scratch...

It should be possible to create an @command node that would replace the headline with the date.

Edward

tbp1...@gmail.com

unread,
Apr 22, 2021, 11:10:27 AM4/22/21
to leo-editor
Here is the simplest thing that could work, I think.  Try this out in your workbook or some equivalent place to make sure it does what you want.

Create a new node, named perhaps "Insert Time in Head". Put the following into the body:

p.h = ''
c.k.simulateCommand('insert-headline-time')

(There may be other ways to activate a Leo command, but this is the one I know about).
Select this node and press the script-button key to make a button for this command.  Now create another new node, and press your new button.  The new node's headline should change to the date, e.g., "4/22".

After you play with this and decide it does what you want, you can move the command over to MyLeoSettings.leo so that it will be available to all outlines.  If you like it as a button, copy the node to the @settings/@buttons subtree, and change the node headline to @button Insert Time in Head

If you want a command but not a button, put its node into the @settings/@commands subtree, and change the node headline to read @command Insert Time in Head.

If you'd like this command to have a keyboard shortcut, add one to the node's headline:  @command Insert Time in Head @key=Alt-F9.

After you restart Leo, your new command will be available to every outline.

jkn

unread,
Apr 22, 2021, 3:37:27 PM4/22/21
to leo-editor

Thanks - I'm familiar (though rusty) with the mechanism of @commands in myLeoSettings.leo etc.

My first experiment following Edward's hint used just

    c.executeMinibufferCommand('insert-headline-time')

(I didn't know about 'c.k.simulatecommand()')

and clearly I can work on the exact behaviour here.

More generally, I was intending to flag the seeming corner-case in behaviour. I will do some experimenting...

Cheers, J^n



Reply all
Reply to author
Forward
0 new messages