-
-
Notifications
You must be signed in to change notification settings - Fork 249
READY: Add lem-tutor interactive tutorial extension #2144
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
Open
Catsquotl
wants to merge
13
commits into
lem-project:main
Choose a base branch
from
Catsquotl:feature/lem-tutor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+720
−0
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3f24b66
WIP: Add lem-tutor interactive tutorial extension
Catsquotl 7c1fbac
Add Lesson 3: buffers and windows, search to Lesson 1, cleanup
Catsquotl 2699c59
Refactor: replaced global defparameters with functions, clean up buff…
Catsquotl 6c78915
Add: error handler for progress loader.
Catsquotl 2a42993
content: rename original.txt to tutorial-basics.txt; clean up command…
Catsquotl 5146b7a
content: update tutorial-basics.txt with command names, capitalizatio…
Catsquotl 2e03ca9
content: expand ADDING CONFIGURATION section with open-init-file example
Catsquotl fdcd4ef
content: add vi-mode mention after Alt-x introduction
Catsquotl 1c1ef25
content: add Lesson 4, update all summaries to 3 column format
Catsquotl eb62fe5
fix: CI bot warnings and errors fixed except line count
Catsquotl 237d8ac
chore: remove LICENSE file and dangling Lesson 6 reference
Catsquotl c6ce48a
feat: added last basic commands, ready for review.
Catsquotl 4b493d3
content: added resources, website links to appendix
Catsquotl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| *.fasl | ||
| *.fas | ||
| *.lib | ||
| *.o | ||
| lem-tutor-saves/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| (defsystem "lem-tutor" | ||
| :depends-on ("lem/core") | ||
| :components ((:file "lem-tutor"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| (defpackage :lem-tutor | ||
| (:use :cl :lem) | ||
| (:export #:tutorial :tutorial-rescan)) | ||
|
|
||
| (in-package :lem-tutor) | ||
|
|
||
| (defun tutorial-text () | ||
| "Set correct paths to core and save files" | ||
| (merge-pathnames "tutorial-basics.txt" (asdf:system-source-directory :lem-tutor))) | ||
|
|
||
| (defun tutorial-save-file () | ||
| (merge-pathnames "lem-tutor-saves/lem-tutor-save.txt" (lem-home))) | ||
|
|
||
| (defun tutorial-progress () | ||
| (merge-pathnames "lem-tutor-saves/lem-tutor-progress.lisp" (lem-home))) | ||
|
|
||
| (define-command tutorial () () | ||
| "Learn Lem interactively with guided exercises and progress tracking." | ||
| (tutorial-mode t)) | ||
|
|
||
| (defun tutorial-save-progress (buffer) | ||
| "Create or update a save file with the cursor position, for easy continuation of the tutorial" | ||
| (let* ((point (buffer-point buffer)) | ||
| (line (line-number-at-point point)) | ||
| (column (point-column point))) | ||
| (with-open-file (stream (tutorial-progress) | ||
| :direction :output | ||
| :if-exists :supersede | ||
| :if-does-not-exist :create) | ||
| (format stream "(:line ~D :column ~D)" line column)))) | ||
|
|
||
| (defun tutorial-load-progress () | ||
| "Load cursor position from progress file and restore cursor position." | ||
| (handler-case | ||
| (when (probe-file (tutorial-progress)) | ||
| (with-open-file (stream (tutorial-progress) | ||
| :direction :input) | ||
| (let* ((plist (read stream)) | ||
| (line (getf plist :line)) | ||
| (column (getf plist :column)) | ||
| (point (buffer-point (find-file-buffer (tutorial-save-file))))) | ||
| (move-to-line point line) | ||
| (move-to-column point column)))) | ||
| (error (e) | ||
| (declare (ignore e)) | ||
| (editor-error "Could not restore latest savepoint. Starting at the top, previously made edits are preserved")))) | ||
|
|
||
| (defun tutorial-enable () | ||
| "Enable tutorial mode: ensure save directory exists, initialize working copy if needed, | ||
| open the save file, store the buffer and hook into after-save for progress tracking." | ||
| (ensure-directories-exist (tutorial-save-file)) | ||
| (unless (probe-file (tutorial-save-file)) | ||
| (uiop:copy-file (tutorial-text) (tutorial-save-file))) | ||
| (let ((buffer (find-file-buffer (tutorial-save-file)))) | ||
| (switch-to-buffer buffer) | ||
| (tutorial-load-progress) | ||
| (add-hook (variable-value 'after-save-hook :buffer buffer) | ||
| #'tutorial-save-progress))) | ||
|
|
||
| (defun tutorial-disable () | ||
| "Save progress when tutorial mode is disabled." | ||
| (tutorial-save-progress (find-file-buffer (tutorial-save-file)))) | ||
|
|
||
| (define-command tutorial-rescan () () | ||
| "Force a syntax rescan of the tutorial buffer" | ||
| (let ((buffer (find-file-buffer (tutorial-save-file)))) | ||
| (lem-tutor/syntax-parser:scan-region | ||
| (buffer-start-point buffer) | ||
| (buffer-end-point buffer)))) | ||
|
|
||
| (define-minor-mode tutorial-mode | ||
| (:name "Lem-tutor" | ||
| :description "A tutorial for the lem editor." | ||
| :enable-hook #'tutorial-enable | ||
| :disable-hook #'tutorial-disable)) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Contractor: error_handling_rule
Contract: contract
AI check failed: "error_handling_rule"
Reason:
User-facing failure handling reports a message directly instead of using
editor-erroras required for messages shown to users.💬 Reply
/dismiss <reason>to dismiss this violation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll see to those soon.