Cheat Sheet: Executing minibuffer commands

135 views
Skip to first unread message

Edward K. Ream

unread,
Apr 1, 2016, 5:14:12 PM4/1/16
to leo-editor
A recent question made me see that there was a big hole in the Cheat Sheet, namely how to use the minibuffer effectively.  Here is the new section:

Alt-X puts focus in the minibuffer. Ctrl-G escapes from the minibuffer.

Once there, you can use tab completion to reduce typing. For example, <Alt-X>open<tab> shows all commands that start with open.

Hit <Enter> to run a complete command.

Ctrl-P (repeat-complex-command) repeat the last command entered from the minibuffer.

Leo maintains a command history list of all minibuffer commands you have entered.

When focus is in the minibuffer, UpArrow shows the previous minibuffer command, and DnArrow show the commands before that.

The body text of an @data history-list setting node preloads commands into the command history list, ignoring lines starting with '#'. For example::

    run-pylint
    beautify-tree
    cff
    sort-lines
    # show-data
    check-clones
    expand-log-pane
    contract-log-pane

Edward

jkn

unread,
May 3, 2017, 6:00:10 AM5/3/17
to leo-editor
Hi Edward - a late followup to this:

The operation of this seems a bit unexpected to me. With the entries in your list above, from startup:

- I press UP-arrow to get the 'first' entry (pylint)
- I have to then press DOWN-arrow to get the rest (in sequence: beautify-tree || cff || sort-lines || etc.). This seems a little illogical

I would expect UP-arrow to give me the last entry in the node: 'contract-log-pane' in this case
Then a 2nd UP-arrow gives me 'expand-log-pane', then DOWN-arrow to give me 'contract-log-pane' again, etc.

Also, I thought I had read that Leo saves command history between sessions, but this doesn't seem to be the case. Am I misremembering? (if so, the @data command-history will probably be good enough for me).

    Thanks
    Jon N

Edward K. Ream

unread,
May 7, 2017, 6:38:55 AM5/7/17
to leo-editor
On Wed, May 3, 2017 at 5:00 AM, jkn <jkn...@nicorp.f9.co.uk> wrote:

The operation of
​[the minibuffer] seems a bit unexpected to me.
​...​

I would expect UP-arrow to give me the last entry in the node
​...​
Then a 2nd UP-arrow gives me 'expand-log-pane', then DOWN-arrow to give me 'contract-log-pane' again, etc.

Also, I thought I had read that Leo saves command history between sessions, but this doesn't seem to be the case.

​Please file two separate enhancement requests for these items.

Edward

jkn

unread,
May 7, 2017, 7:47:32 AM5/7/17
to leo-editor


OK. I am close to having a patch for the first part of this...

    Regards
    Jon N

jkn

unread,
May 18, 2017, 5:29:06 PM5/18/17
to leo-editor
Hi Edward
    OK, here's a diff to leyKeys.py which seems to give the Command History behaviour I like & expect ;-)

It took me a while to get here - the key was to realise that there is a state outside the normal range of the commandIndex; in fact the Command History traversal is entered in this state.

I indicate this by setting k.commandHistory to None, but there are other ways to achieve this that you might prefer.

A couple of other slight changes:

- I use 'commandHistoryFwd()' and 'commandHistoryBackwd()' instead of 'commandHistoryUp' and 'commandhistoryDown()'. I found this easier to picture, especially since there is some list reversing going on...
- I added a 'resetCommandhistory()' method and call, so that exiting the minibuffer causes the command History index to be reset. I think this is done in the right place. Again, this is behaviour I expect.

I hope this method of attaching the diff is useful. I had to trim down the full diff; my (non-leo ;-o) editor settings trim trailing spaces when writing .py files, and there seem to be quite a few in leoKeys.py. Perhaps worth a tidy up someday?

Do you still want me to raise an enhancement request for this, or will this suffice? I will raise a request on the other feature (command history saved between sessions) in any case.

    Regards
    Jon N
leoKeys.diff

Edward K. Ream

unread,
Jun 1, 2017, 10:49:26 AM6/1/17
to leo-editor
On Thu, May 18, 2017 at 4:29 PM, jkn <jkn...@nicorp.f9.co.uk> wrote:
Hi Edward
    OK, here's a diff to leyKeys.py which seems to give the Command History behaviour I like & expect ;-)

​Thanks for this.  Rev 0308cd applies the patch. It works well, and all unit tests pass.  Many thanks for this work.

Edward

jkn

unread,
Jun 3, 2017, 5:18:09 PM6/3/17
to leo-editor
Hi Edward

Glad it was useful. I will probably raise the other as an enhancement request, but getting @data history-list working 'seamless;y' will make a big difference to me in any case. there would have to be some though given as to how to reconcile this mechanism and the history given by commands executed within a session in any case.

    Regards
    jon N

Edward K. Ream

unread,
Jun 19, 2017, 4:59:49 PM6/19/17
to leo-editor
On Wed, May 3, 2017 at 5:00 AM, jkn <jkn...@nicorp.f9.co.uk> wrote:

Also, I thought I had read that Leo saves command history between sessions, but this doesn't seem to be the case.

​I found this unanswered question while documenting what you did.

The only way to "remember" command history between sessions is to update the @data command-history node.

The situation is similar to trying to "remember" the toggle-split-direction command.  That's also not possible because there is already a setting that specifies the initial split direction.

Edward

jkn

unread,
Jun 20, 2017, 4:38:42 AM6/20/17
to leo-editor
Hi Edward

I haven't been particularly following the discussion about toggle-split direction, but I think I see things a little different to you.

The Bash history facility (for example) use a file (~/.bash-history by default) which stores the last N commands entered. So I had in mind something similar, which could be loaded at the start of a session, maintained as commands are entered and executed, and saved before exit. I would keep the number of commands stored relatively small (N = 50 or 100, perhaps).

The 'problem' then would be: how, at the start of a session say, would the commands in @data command-history be 'reconciled' with the contents of the .history file? One could imagine them being concatenated, but other schemes are possible, and I am not sure there is a definitively best answer.

    Jon N

Edward K. Ream

unread,
Jun 20, 2017, 9:58:15 AM6/20/17
to leo-editor
On Tue, Jun 20, 2017 at 3:38 AM, jkn <jkn...@nicorp.f9.co.uk> wrote:

I haven't been particularly following the discussion about toggle-split direction, but I think I see things a little different to you.

Maybe ;-)​

The Bash history facility (for example) use a file (~/.bash-history by default) which stores the last N commands entered. So I had in mind something similar, which could be loaded at the start of a session, maintained as commands are entered and executed, and saved before exit. I would keep the number of commands stored relatively small (N = 50 or 100, perhaps).

The 'problem' then would be: how, at the start of a session say, would the commands in @data command-history be 'reconciled' with the contents of the .history file? One could imagine them being concatenated, but other schemes are possible, and I am not sure there is a definitively best answer.

Imo, settings are incompatible with automatic operation.  Settings promise stability. Updating them automagically breaks that promise.

Imo, the history settings are good enough. I have no plans to replace them.

Edward

jkn

unread,
Jun 20, 2017, 4:25:04 PM6/20/17
to leo-editor
Hi Edward

I'm not quite sure of your terminology here; I would call @data command-history a setting, and ~/.leo-history as persistence, along the lines of having the same session as last time.

I agree that there is a tension between these two approaches, and the command-history node is working well enough for me to live with, so I shan't press the point...

    Regards
    Jon N

Reply all
Reply to author
Forward
0 new messages