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

Manual section on prompt buffer. #2772

Closed
wants to merge 1 commit into from
Closed

Conversation

aadcg
Copy link
Member

@aadcg aadcg commented Feb 7, 2023

A follow up of the manual section drafted in #2655.

Description

Work in progress. I'll let you know when to take a look @aartaka.

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.
    • (If this changes something about the features showcased on Nyxt website) I have these changes described in the new/existing article at Nyxt website or will notify one of maintainters to do so.
  • 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 changed the title Draft manual section on prompt buffer. Manual section on prompt buffer. Feb 7, 2023
@aadcg aadcg force-pushed the prompt-buffer-manual branch 2 times, most recently from 7975faf to c98cd66 Compare February 14, 2023 13:58
@aadcg
Copy link
Member Author

aadcg commented Feb 14, 2023

I will be backporting an article written by @Ambrevar which serves as the base to a section called "Programming Interface".

To be converted in the final manual format at the last moment.
@aadcg
Copy link
Member Author

aadcg commented Feb 16, 2023

The first draft of the prompt buffer manual section is ready (still in .org mode so that editing is easier, it will be converted to our format at the last minute).

At this point we should validate the following:

  • The logical ordering of the sections;
  • The amount of information - what is missing or extra?;
  • The clarity of each section.

Broadly speaking, there are two distinct sections in the document. In the first part, the target is the user. In the second, (introduced by "Programming Interface") the target is the developer.

Ideally, everyone should read and review it. CC @aartaka @Ambrevar @jmercouris.

@aadcg aadcg self-assigned this Feb 16, 2023
@Ambrevar
Copy link
Member

To clarify, do you want a review now or when you will be done with the draft?

@aadcg
Copy link
Member Author

aadcg commented Feb 16, 2023

@Ambrevar now, the draft is ready to review.

toggle-mark-backwards
toggle-mark-all

Once the current suggestion (or the marks) is set, hitting the Return key to
Copy link
Contributor

Choose a reason for hiding this comment

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

Spurious "to"?

next-source
previous-source

Oftentimes, you will interact with a collection of suggestions, which we call
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe mention why we use marks—to act on more than one suggestion at a time?

Notice that the contents of the input bar is matched against all suggestion
attributes shown.

The syntax of regular expressions is not supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

"... but configurable"?


Within the :nyxt package, a set of primitives is defined on top of :prompter to
suit the browser's needs. Additionally, the package :nyxt/prompt-buffer-mode
defines the relevant mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does mode do? It's worth mentioning that it hosts necessary commands and keybindings.

define an example-source:

#+begin_src lisp
(defun set-suggestions (n)
Copy link
Contributor

Choose a reason for hiding this comment

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

This additional function may be quite confusing. I'd rather use something simpler (inline constructor?), at least for the first appearance of sources.

:sources (make-instance 'example-source))
#+end_src

Sources can be inspected with the describe-class command. Particularly
Copy link
Contributor

Choose a reason for hiding this comment

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

Dunno whether this describe-class reference belong here. But the source listing, augmented with :nxref links is a worthy thing.

- =prompter:actions-on-marks=

An action is either a symbol or a command, that may be locally-defined by either
=lambda-mapped-command= or =lambda-command=.
Copy link
Contributor

Choose a reason for hiding this comment

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

lambda-unmapped-command is useful too.


The =prompter:object-attributes= method serves precisely that purpose. It
enables displaying something more meaningful than the standard printed
representation of class instance =#<CLASS-NAME {ID}>=.
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this representation is not really standardized beyond the sharp-less-than syntax. SBCL, CCL, ECL, and other implementations have it slightly different.

SBCL:

#<FOO {100833DF63}>

CCL:

#<FOO #x302000F91BBD>

ECL:

#<a COMMON-LISP-USER::FOO 0x7fbe8c6e62c0>

Finally, the =prompter:filter-postprocessor= is run of the result of the filter,
this time again over the entire list at once.

Once again, the source view is only updated when the postprocessor is done with
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention that postprocessor is asynchronous, in contrast to preprocessor?

The class is useful to store information through the processing pipeline
described in the previous section. For instance, the filter can calculate and
store the score of each suggestion, in the =score= slot, which in turn is
readily available to the =filter-postprocessor= for sorting.
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention the prompter:suggestion-maker here and add an example code to redefine it?

@@ -0,0 +1,283 @@
* Prompt buffer
The prompt buffer is a special buffer where Nyxt commands read arguments, such
Copy link
Member

Choose a reason for hiding this comment

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

"arguments" -> "user input"

* Prompt buffer
The prompt buffer is a special buffer where Nyxt commands read arguments, such
as URLs, file names or Common Lisp expressions. We call it prompt buffer
because, as the name suggests, it prompts the user for textual input.
Copy link
Member

Choose a reason for hiding this comment

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

Last sentence is probably unnecessary.


Each suggestion belongs to a source. Sources define consistent umbrellas for
specific use cases. For example, the command describe-any has sources for
variables, functions and classes.
Copy link
Member

Choose a reason for hiding this comment

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

and more.

When invoked, the prompt buffer occupies the lower region of the screen, and the
cursor is set at the top bar, featuring: the prompter message on the left, the
input area at the center and the active modes on the right. The suggestions are
listed vertically below the top bar, and are shown before you start typing.
Copy link
Member

Choose a reason for hiding this comment

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

Calling it the "top bar" may not be future-proof, e.g. if the prompt is displayed on top of the window.
Maybe "input area"?

next-page
previous-page
next-source
previous-source
Copy link
Member

Choose a reason for hiding this comment

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

Use hyphens (-) for listings.

The system nyxt/prompter (containing the :prompter package) defines the
primitives that make prompt buffers possible in Nyxt.

Within the :nyxt package, a set of primitives is defined on top of :prompter to
Copy link
Member

Choose a reason for hiding this comment

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

What is :prompter?

# Link to slots.
# (:nxref :slot 'prompter:constructor :class-name 'prompter:source)

You can further study it by looking at prompter:source.
Copy link
Member

Choose a reason for hiding this comment

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

Inspect prompter:source for more details.


#+begin_src lisp
(prompt :prompt "Prompter"
:sources (make-instance 'example-source))
Copy link
Member

Choose a reason for hiding this comment

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

You can show the full form with :sources (list (make-instance ...)) and then show the shortcut with neither list nor make-instance.

An action is either a symbol or a command, that may be locally-defined by either
=lambda-mapped-command= or =lambda-command=.

Regardless, actions are functions that takes a list as a sole argument - either
Copy link
Member

Choose a reason for hiding this comment

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

typo: "that take"


This filter function is particularly useful to score suggestions by relevance.

Finally, the =prompter:filter-postprocessor= is run of the result of the filter,
Copy link
Member

Choose a reason for hiding this comment

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

"on the result"?

@jmercouris
Copy link
Member

@aadcg can I review and merge this?

@aadcg
Copy link
Member Author

aadcg commented Oct 30, 2023

@jmercouris your review would be a waste of time. A lot has changed ever since with respect to the prompt buffer. Also, it's still an org file, since I don't think humans are meant to write documentation in spinneret.

I don't like PR that are "marinating" but I'll do it by the next major release.

@aadcg aadcg added the 4-series Related to releases whose major version is 4. label Oct 30, 2023
@jmercouris
Copy link
Member

If you would like to use org-mode, we would lose /a lot/ of the abilities we have right now. I think our documentation has become a lot more rich because of embedding it directly into the source code. The only thing I might suggest, that might make writing documentation easier would be an embeddable DSL. That is however a large project, and a discussion for a different time.

@aadcg
Copy link
Member Author

aadcg commented Dec 5, 2023

@jmercouris, as I've mentioned above this PR is still a draft and the current state just helps to edit faster.

still in .org mode so that editing is easier, it will be converted to our format at the last minute

See #2674

@jmercouris jmercouris closed this Dec 7, 2023
@jmercouris jmercouris deleted the prompt-buffer-manual branch December 7, 2023 19:59
@aadcg
Copy link
Member Author

aadcg commented Dec 7, 2023

@jmercouris given the above exchange, closing the PR comes as a surprise:

(@aadcg) I don't like PR that are "marinating" but I'll do it by the next major release.

I'm OK with the decision, as I still have the changes saved in a local branch, but a warning or explanation wouldn't hurt!

@jmercouris
Copy link
Member

I'm sorry, it was again an accident, the stupid page froze on my machine and I don't even know what it clicked or didn't. I meant to only close the PR, not delete the branch! I just wanted to remove clutter and keep only the fresh active things in view.

@aadcg
Copy link
Member Author

aadcg commented Dec 8, 2023

All clear, let's keep it as is regardless!

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

Successfully merging this pull request may close these issues.

None yet

4 participants