Skip to content

WIP: Add lem-tutor interactive tutorial extension#2144

Draft
Catsquotl wants to merge 2 commits intolem-project:mainfrom
Catsquotl:feature/lem-tutor
Draft

WIP: Add lem-tutor interactive tutorial extension#2144
Catsquotl wants to merge 2 commits intolem-project:mainfrom
Catsquotl:feature/lem-tutor

Conversation

@Catsquotl
Copy link
Copy Markdown

Closes #1967

  • Alt-x tutorial opens an interactive tutorial buffer
  • Working copy saved to (lem-home)/lem-tutor-saves/
  • Cursor position persisted across sessions
  • Lesson 1: Movement
  • Lesson 2: Files and Configuration

This PR does not include tests. Given the code I am unsure what those would even look like.

To review and test:

  1. Add extensions/lem-tutor/ to your ASDF source registry
  2. (ql:quickload :lem-tutor)
  3. Alt-x tutorial

Claude AI did not write the code, helped me reason through it and held my hand at through most mistakes though

Closes lem-project#1967

- Alt-x tutorial opens an interactive tutorial buffer
- Working copy saved to (lem-home)/lem-tutor-saves/
- Cursor position persisted across sessions
- Lesson 1: Movement
- Lesson 2: Files and Configuration

(in-package :lem-tutor)
(defparameter *tutorial-text* (merge-pathnames "original.txt" (asdf:system-source-directory :lem-tutor)))
(defparameter *save-file* (merge-pathnames "lem-tutor-saves/lem-tutor-save.txt" (lem-home)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

orange flag here: calling merge-pathname and (lem-home) at the top-level works on your machine, but if you share a binary to users/friends, they will have your value in the parameter, and this won't work on their machine. Same on CI. Solution: wrap in a function.

;; exple:
(defparameter *foo* nil)
(defun foo ()
   (if *foo*  
      *foo*
      (setf *foo* (merge-pathname …)))

(when (probe-file *progress-file*)
(with-open-file (stream *progress-file*
:direction :input)
(let* ((plist (read stream))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add error handling maybe, just in case? You never know what users do :p

@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2026 Catsquotl
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is a LICENSE file necessary? First time I see it in extensions/.

Alt-x Hold Alt, press x
C-x C-c Hold Control, press x; then hold Control, press c

"C-" means Control. "M-" means Alt.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would quite like that we wrote Alt and not M ! No ?

(we can say in passing that sometimes we write M- for Alt, it helps)


Every action in lem is a named command. Keys are shortcuts to commands,
but there are many commands that have no key binding at all. You can call any command
by name with Alt-x.
Copy link
Copy Markdown
Collaborator

@vindarel vindarel Apr 21, 2026

Choose a reason for hiding this comment

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

+1 for Alt- ^^

=========
INTRODUCTION

You are reading lem-tutor, an interactive tutorial for the lem editor.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpick: lem with a capital Lem ?

QUITTING

To leave lem:
C-x C-c Quit lem
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here, sometimes, or always, give the equivalent command name that we can call with Alt- ? To remind we don't have to memorize keys but we can find commands.

-----
>> C-x C-c
-----
To return to this tutorial after quitting: Alt-x lem-tutor.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is lem-tutor correct or can we call Alt-tutorial too ?

C-v Scroll down one screen
M-v Scroll up one screen

This lesson covers the rest.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shall we mention in passing that Lem has a vi-mode? So power-users that didn't know can try right away, others can carry on the tutorial. vi-mode would not be taught here.

your call.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've thought about adding an option to choose lem or vi mode for the tutorial. Maybe worth revistliting at this point? Or just assume vi-mode users know what they are doing. I am unsure if that is always the case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we can revisit later, let's not double the work for this tutorial first pass. I assume vi-mode users know what they do yeah.


Its location is one of:
~/.lem/init.lisp
~/.config/lem/init.lisp (Lem 2.2 and later)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggesting to only mention the new 2.2 location

or to enable them permanently at startup:

(add-hook *after-init-hook* (lambda ()
(lem/line-numbers:toggle-line-numbers)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

They don't have the same effect? The one-liner seems to be working, no?

Copy link
Copy Markdown
Author

@Catsquotl Catsquotl Apr 21, 2026

Choose a reason for hiding this comment

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

That was deliberate so the user would at least have 2 buffers open to play with in the buffer section and get some hands on experience on editing and configuring lem.

@vindarel
Copy link
Copy Markdown
Collaborator

👌 I love the progression.

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.

Write a built-in tutorial

2 participants