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

[WIP] Tutorial proposal #1144

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

[WIP] Tutorial proposal #1144

wants to merge 6 commits into from

Conversation

lisael
Copy link
Contributor

@lisael lisael commented Jan 19, 2017

Here's a proposal to address #1122. This adds a :tutorial command that opens a tutorial where one can navigate page by page.

There's a mechanism to chose the tutorial language, a draft of a few lessons, added as simple .md file.

I show it now to validate the design, not the content (there must be a lot of gramar and syntax oddities as, I'm not a native English speaker).

I think, if the design is validated, we should resolve wether the tutorial must remain in the main kakoune repo or live in its own repository to avoid poluting the issues with ToC choices, wording, translations and such.

Thank you for the feedback.

Copy link
Owner

@mawww mawww left a comment

Choose a reason for hiding this comment

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

Hello,

Thanks very much for this proposal, its a very good starting point.

I think the markdown files should be converted to asciidoc (they probably just need renaming, markdown is usually valid asciidoc) to stay consistent with other documentation pages.

Also, they should be in doc/tutorial instead of rc/tutorial.

And it probably requires a few more advanced pages, introducing multiple selections, s/S <a-k>/<a-K>, word based movements...

Edit: just saw that its mostly for design validation, I think the design is sound, and it can be worked on in a branch of the main repo until we deem it ready.

- `i` inserts before the selection
- `A` moves the selection to the last character of the line and append text

Some move commands perform selecting moves, i.e. the anchor is fixed and only
Copy link
Owner

Choose a reason for hiding this comment

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

I think expanding would be a better word than selecting for these moves.

previous page.

The tutorial pages are editable and contain instructions to change them. At
any time, you cah restore the pages to their original content with `<<esc>,r`.
Copy link
Owner

Choose a reason for hiding this comment

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

typo (cah instead of can)

8. When comfortable, go to the next lesson

...> There all words
...> There are missing words here.
Copy link
Owner

Choose a reason for hiding this comment

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

Its not clear to me what edit should be done here.

2. Give direct feedback to the user (with the help box)
3. Incite the user to create and adapt their own tools

Thus, the main documentation should remain a single web page : https://github.com/mawww/kakoune/blob/master/README.asciidoc
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure about that, we do have the :doc command thats expected to replace the README.

@lisael
Copy link
Contributor Author

lisael commented Jan 20, 2017

I moved tutorial.kak into rc/base/

def tutorial -params .. -docstring %{ Run the kakoune tutorial } -allow-override %{
%sh{
[ $# -gt 0 ] && tutlang="$1" || tutlang="en"
echo "set global tutorial_dir $(dirname ${kak_opt_tutorial_source})/../../doc/tutorial/$tutlang"
Copy link
Contributor

Choose a reason for hiding this comment

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

Use printf here for POSIX correctness.

def -hidden tutorial-load -params 0..1 -allow-override %{
%sh{
bufname="*${kak_opt_tutorial_lesson}*"
if [ $(echo "${kak_buflist}" | grep "${bufname}") ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

printf

%sh{
bufname="*${kak_opt_tutorial_lesson}*"
if [ $(echo "${kak_buflist}" | grep "${bufname}") ]; then
echo "buffer ${bufname}"
Copy link
Contributor

Choose a reason for hiding this comment

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

printf

if [ $(echo "${kak_buflist}" | grep "${bufname}") ]; then
echo "buffer ${bufname}"
else
echo "edit -scratch ${bufname}"
Copy link
Contributor

Choose a reason for hiding this comment

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

printf

echo "buffer ${bufname}"
else
echo "edit -scratch ${bufname}"
echo "tutorial-reload $@"
Copy link
Contributor

Choose a reason for hiding this comment

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

printf

if [ "$1" = "-no-nav" ]; then
nav=false
fi
echo "exec -draft -client ${kak_client} \%d"
Copy link
Contributor

Choose a reason for hiding this comment

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

printf

nav=false
fi
echo "exec -draft -client ${kak_client} \%d"
if $nav ; then
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use [ -n "$nav" ] here

fi
echo "exec -draft -client ${kak_client} \%d"
if $nav ; then
echo "exec -draft -client ${kak_client} |cat<space>${kak_opt_tutorial_dir}/meta-nav.md<ret>\;"
Copy link
Contributor

Choose a reason for hiding this comment

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

printf

fi
echo "exec -draft -client ${kak_client} ge|cat<space>${kak_opt_tutorial_dir}/${kak_opt_tutorial_lesson}<ret>\;"
echo "exec -client ${kak_client} gg"
# echo "exec -draft -client ${kak_client} ggO\`<lt>esc<gt>,h\`<space>previous<space>page<esc> Qa<space><esc><esc>35q anext<space>page<space>\`<lt>esc<gt>,l\`<esc> o<esc>"
Copy link
Contributor

Choose a reason for hiding this comment

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

printf on the last 3 lines


def tutorial-prev -allow-override %{
%sh{
next=$(ls "${kak_opt_tutorial_dir}" | grep -v "meta-" | grep -B 1 "${kak_opt_tutorial_lesson}" | head -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

ls -1 would be safer here I think, and the -B flag for grep isn't POSIX.

def tutorial-prev -allow-override %{
%sh{
next=$(ls "${kak_opt_tutorial_dir}" | grep -v "meta-" | grep -B 1 "${kak_opt_tutorial_lesson}" | head -1)
echo "set global tutorial_lesson $next"
Copy link
Contributor

Choose a reason for hiding this comment

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

printf

@lenormf
Copy link
Contributor

lenormf commented Jan 21, 2017

Why are all the functions declared as overridable?

@lisael
Copy link
Contributor Author

lisael commented Jan 21, 2017

@lenormf It's a work in progress, I just have to reload the file to test the functions, I remove the -allow-override when I'm satisfied. Thank you for the POSIX advices.

@lenormf
Copy link
Contributor

lenormf commented Jan 22, 2017

I hadn't seen that there's also an -A flag passed to grep, as well as a -B one. Those are probably not available on all implementations of grep, so they will have to go.

@lisael
Copy link
Contributor Author

lisael commented Jan 22, 2017

Yes, I saw that, I didn't fix -[A|B] yet, because it's less obvious as echo -> printf. I read the POSIX man for grep, it's pretty limited. I probably have to convert the grep to a sed or awk script.

@lenormf
Copy link
Contributor

lenormf commented Jan 22, 2017

Welcome to cross platform shell script compatibility hell!

@lisael
Copy link
Contributor Author

lisael commented Jan 22, 2017

:)

awk did the trick (I checked, -v is POSIX awk)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants