Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selection actions list #2555

Merged
merged 5 commits into from
Nov 9, 2022
Merged

Selection actions list #2555

merged 5 commits into from
Nov 9, 2022

Conversation

aadcg
Copy link
Member

@aadcg aadcg commented Sep 8, 2022

Description

Add the ability to choose from a list of selection-actions.
Simplify return-actions by ensuring it's a list.

Fixes #2198

Discussion

Also, I want to test this API with the hinting system. I can imagine it being very helpful in that context.

Checklist:

Everything in this checklist is required for each PR. Please do not approve a PR that does not have all of these items.

  • I have pulled from master before submitting this PR
  • There are no merge conflicts.
  • I've added the new dependencies as:
    • ASDF dependencies,
    • Git submodules,
      cd /path/to/nyxt/checkout
      git submodule add https://gitlab.common-lisp.net/nyxt/py-configparser _build/py-configparser
    • and Guix dependencies.
  • My code follows the style guidelines for Common Lisp code. See:
  • I have performed a self-review of my own code.
  • My code has been reviewed by at least one peer. (The peer review to approve a PR counts. The reviewer must download and test the code.)
  • Documentation:
    • All my code has docstrings and :documentations written in the aforementioned style. (It's OK to skip the docstring for really trivial parts.)
    • I have updated the existing documentation to match my changes.
    • I have commented my code in hard-to-understand areas.
    • I have updated the changelog.lisp with my changes if it's anything user-facing (new features, important bug fix, compatibility breakage).
    • I have added a migration.lisp entry for all compatibility-breaking changes.
  • Compilation and tests:
    • My changes generate no new warnings.
    • I have added tests that prove my fix is effective or that my feature works. (If possible.)
    • New and existing unit tests pass locally with my changes.

@aadcg aadcg force-pushed the selection-actions-list branch from 1c64590 to 8ad1bf7 Compare September 8, 2022 15:23
@aadcg aadcg requested review from aartaka and Ambrevar September 8, 2022 15:25
@aadcg
Copy link
Member Author

aadcg commented Sep 8, 2022

@aartaka, @Ambrevar take a first quick look to make sure I'm not doing anything too silly.

@aartaka
Copy link
Contributor

aartaka commented Sep 8, 2022

I don't see anything outright silly there yet ;)

@Ambrevar
Copy link
Member

Ambrevar commented Sep 9, 2022

You might have misunderstood the point of C-j: it's to run a selection action manually, in case follow-mode is not enabled.

So you'd need to restore call-selection-action since otherwise the user has no way to manually call an action.

Rest looks good to me, but I haven't tested yet.

@aadcg aadcg force-pushed the selection-actions-list branch 4 times, most recently from ef7ed5a to a829e5f Compare September 12, 2022 11:38
@aadcg
Copy link
Member Author

aadcg commented Sep 12, 2022

You might have misunderstood the point of C-j: it's to run a selection action manually, in case follow-mode is not enabled.

For the sake of clarity, follow-mode is a deprecated concept and we now call it auto-return-p.

I don't follow. Notice that auto-return-p only concerns return-actions, not selection-actions.

So you'd need to restore call-selection-action since otherwise the user has no way to manually call an action.

Which actions are you referring to? We have return-actions, selection-actions and marks-actions.

Can we give an example?

@aadcg
Copy link
Member Author

aadcg commented Sep 12, 2022

Also, on master, running run-selection-action (bound to C-j in Emacs-mode) has no effect.

@Ambrevar
Copy link
Member

For the sake of clarity, follow-mode is a deprecated concept and we now call it auto-return-p.

I don't follow. Notice that auto-return-p only concerns return-actions, not selection-actions.

That's your confusion: follow-mode has been renamed to selection-actions-enabled-p.

Try the jump-to-heading command and navigate the selections to see its effect.

Copy link
Contributor

@aartaka aartaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree with @Ambrevar—we need manual escape hatch in the form of (call|run)-selection-action.

libraries/prompter/prompter.lisp Outdated Show resolved Hide resolved
source/browser.lisp Outdated Show resolved Hide resolved
source/history.lisp Outdated Show resolved Hide resolved
"M-return" 'return-selection-over-action
"C-return" 'run-selection-action
"M-return" 'return-marks-action
"C-return" 'set-selection-action
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use some other binding? C-return is usually used to mark something like forced send or definitive approval. On GitHub, it's used to send commentaries (because mere return is used to insert newline), for example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a reasonable argument to me.

Any suggestion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aartaka please review the keybindings.

source/mode/prompt-buffer.lisp Outdated Show resolved Hide resolved
source/mode/repeat.lisp Outdated Show resolved Hide resolved
@aadcg
Copy link
Member Author

aadcg commented Sep 13, 2022

That's your confusion: follow-mode has been renamed to selection-actions-enabled-p.

You're correct! Sorry.

Now let's go back to the main topic that you have raised:

You might have misunderstood the point of C-j: it's to run a selection action manually, in case follow-mode is not enabled.

So you'd need to restore call-selection-action since otherwise the user has no way to manually call an action.

selection-actions-enabled-p is nil by default. Some modes override it of course.

We have the command toggle-selection-actions-enabled that toggles selection-actions-enabled-p. Now that selection-actions can be manifold, we need an extra command to select the default action (set-selection-action).

Does it really make sense to have a command that enables a selection-action to run once?

@aadcg aadcg force-pushed the selection-actions-list branch 2 times, most recently from 74e002b to fc4f9ed Compare September 13, 2022 11:40
@Ambrevar
Copy link
Member

Now that selection-actions can be manifold, we need an extra command to select the default action (set-selection-action).

Correct!

Does it really make sense to have a command that enables a selection-action to run once?

Can you give an example?

@aadcg aadcg force-pushed the selection-actions-list branch from ddfa96c to 5f23aba Compare September 13, 2022 13:48
@aadcg
Copy link
Member Author

aadcg commented Sep 13, 2022

Can you give an example?

Ok, let's take this slowly. It seems that both @Ambrevar and @aartaka raised concern about the fact that I've deprecated the command run-selection-action. I'll explain my reasoning below.

Let's take the command jump-to-heading, for which selection-actions-enabled-p is set to t.

Let me describe the behavior on master. When we issue the command interactively, it's possible to disable selection-actions (scrolling in this case) by issuing the command toggle-selection-actions-enabled while the prompt is active. Now that selection-actions-enabled-p is set to nil, the command run-selection-action runs the action once. Personally, I think that toggle-selection-actions-enabled, while different, is general enough for me not to use run-selection-action.

With this PR, I add the possibility to define several selection-actions. Obviously a new command is needed to set the action, without leaving the prompt. Given my comment above on the generality of toggle-selection-actions-enabled, and the fact that a new command is needed, I thought it would be sensible to bind this new command to the key that was once bound to run-selection-action.

If you consider that we really need 3 commands for cover all of this, I don't oppose. I just think it may be overkill. Perhaps there are use cases that I'm actually disregarding!

@aadcg aadcg force-pushed the selection-actions-list branch from ee9f1ee to 2dbbbaf Compare September 13, 2022 14:42
@aadcg aadcg mentioned this pull request Sep 13, 2022
4 tasks
@Ambrevar
Copy link
Member

Ambrevar commented Sep 14, 2022

OK, makes sense now, thanks for the detailed review.

So yes, I believe we need 3 commands, because selection action may need to be only manual, in which case we need a trigger key. jump-to-heading only scrolls, so this is rather innocent, but imagine a selection action that, say, downloads the hint! In this case you want to be careful and not accidentally trigger the selection action.

EDIT: Clarify action -> command

@aartaka
Copy link
Contributor

aartaka commented Sep 14, 2022

So yes, I believe we need 3 commands, because selection action may need to be only manual, in which case we need a trigger key.

Yes!

jump-to-heading only scrolls, so this is rather innocent, but imagine a selection action that, say, downloads the hint! In this case you want to be careful and not accidentally trigger the selection action.

jump-to-heading is not innocent—it throws you to the start of the document once you start selecting prompt suggestions! I even think that we should make its default-selection-action purely manual, because we don't yet have a good way to make it smooth ヽ(o`皿′o)ノ

EDIT: it's -> its

@aadcg
Copy link
Member Author

aadcg commented Sep 14, 2022

Commit f96d8ba introduced a major bug in the hinting interface. At least the one who did it will clean up the mess! Sorry everyone.

@aadcg aadcg mentioned this pull request Sep 15, 2022
19 tasks
@aadcg aadcg force-pushed the selection-actions-list branch 2 times, most recently from 986d5f1 to 065da5d Compare October 17, 2022 11:47
@aadcg aadcg force-pushed the selection-actions-list branch from 020a8fe to 6cc7af8 Compare November 1, 2022 10:47
@aadcg
Copy link
Member Author

aadcg commented Nov 1, 2022

You have a point, even though it seems to be too much work for little to no benefit. Let's stick to what you suggest :)

@Ambrevar
Copy link
Member

Ambrevar commented Nov 1, 2022

Sorry for being overly picky, but the prompter library is the most sensitive part of Nyxt, so we should try to be as clean as possible. It will help us a lot in the future if things go wrong.

@aadcg aadcg force-pushed the selection-actions-list branch from 6cc7af8 to 65fba69 Compare November 2, 2022 09:24
@aadcg
Copy link
Member Author

aadcg commented Nov 2, 2022

No need to close this PR, as I've been breaking the former one into smaller ones.

About keybindings:

We need a new keybinding for set-selection-action. Does C-c C-j make sense? @aartaka @Ambrevar @jmercouris

@aadcg aadcg force-pushed the selection-actions-list branch from 65fba69 to 4492cf1 Compare November 2, 2022 09:52
@aadcg aadcg requested a review from Ambrevar November 2, 2022 09:55
@Ambrevar
Copy link
Member

Ambrevar commented Nov 2, 2022

C-c C-j is fine from a Helm user perspective, but maybe a bit arcane for everyone else.

What about C-c return? Or C-u return?

@@ -330,6 +330,9 @@ call."))
(alex:when-let ((action (first (marks-actions source))))
(run-thread "Prompter mark action thread" (funcall action (marks source)))))

(defmethod default-selection-action ((source prompter:source))
(first (slot-value source 'selection-actions)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same. The reason why I refrained myself from exporting is due to default-return-action, which isn't exported. I don't see any reason why these shouldn't be consistent.

@aartaka
Copy link
Contributor

aartaka commented Nov 2, 2022

  • Why did you decide to change the M-return keybinding?

Because M-return should be reserved for some "strong" action closing the prompt-buffer, analogous to return and C-return (return stands either for "activate this now" or "I'm done, commit this action" in CUA). If we dilute the responsibility one takes when pressing M-return, then the character of other actions bound to *-return will not be perceived as final and decisive for a given prompt.

@aadcg
Copy link
Member Author

aadcg commented Nov 2, 2022

C-c C-j is fine from a Helm user perspective, but maybe a bit arcane for everyone else.

What about C-c return? Or C-u return?

I guess I still prefer C-c C-j, but I don't have any strong opinion.

@aadcg
Copy link
Member Author

aadcg commented Nov 2, 2022

  • Why did you decide to change the M-return keybinding?

Because M-return should be reserved for some "strong" action closing the prompt-buffer, analogous to return and C-return (return stands either for "activate this now" or "I'm done, commit this action" in CUA). If we dilute the responsibility one takes when pressing M-return, then the character of other actions bound to *-return will not be perceived as final and decisive for a given prompt.

Seems absolutely sound to me, but let's perhaps leave it out of this PR. We should revise all keybindings before 3.0.

@Ambrevar Ambrevar added the 3-series Related to releases whose major version is 3. label Nov 3, 2022
@aadcg aadcg force-pushed the selection-actions-list branch from 4492cf1 to 88594d1 Compare November 7, 2022 13:54
@aadcg
Copy link
Member Author

aadcg commented Nov 7, 2022

Updated changelog, should be ready to merge. @Ambrevar.

@Ambrevar
Copy link
Member

Ambrevar commented Nov 9, 2022

Looks good to me!

aadcg added 5 commits November 9, 2022 12:48
Logic refactoring, since it handled lists of a single element.
Add set-selection-action.

Keybindings review.

Rename return-selection-over-action to return-marks-action.  According to the
terminology of the prompter library, return-actions run over marks, not over the
selection.

Rename action-source to return-action-source to distinguish it from
selection-action-source.
@aadcg aadcg force-pushed the selection-actions-list branch from 856deea to 0957dec Compare November 9, 2022 10:48
@aadcg aadcg merged commit ade2e55 into master Nov 9, 2022
@aadcg aadcg deleted the selection-actions-list branch November 9, 2022 10:49
@aadcg
Copy link
Member Author

aadcg commented Nov 9, 2022

Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3-series Related to releases whose major version is 3.
Development

Successfully merging this pull request may close these issues.

Leverage selection-actions as a list
3 participants