mirror of
https://github.com/doomemacs/doomemacs.git
synced 2026-01-18 23:21:22 -08:00
feat(tutorial): add progress save/loading
This commit is contained in:
parent
474d7d4212
commit
18046fa543
1 changed files with 31 additions and 0 deletions
|
|
@ -1,5 +1,36 @@
|
|||
;;; config/tutorial/autoload/tutorial.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar doom-tutorial-hist-file
|
||||
(expand-file-name "tutorial-progress.el" doom-cache-dir)
|
||||
"Directory where tutorial progress information is saved.")
|
||||
|
||||
(defvar doom-tutorial--progress
|
||||
(when (file-exists-p doom-tutorial-hist-file)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents doom-tutorial-hist-file)
|
||||
(read (current-buffer))))
|
||||
"An alist of tutorials and progress information.")
|
||||
|
||||
(defun doom-tutorial--save-progress ()
|
||||
"Write `doom-tutorial--progress' to `doom-tutorial-hist-file'."
|
||||
(with-temp-buffer
|
||||
(insert
|
||||
";; -*- mode: emacs-lisp -*-\n"
|
||||
";; Tutorial progress file, automatically generated by `doom-tutorial--save-progress'.\n"
|
||||
"\n")
|
||||
(let ((print-length nil)
|
||||
(print-level nil)
|
||||
(print-quoted t))
|
||||
(prin1 doom-tutorial--progress
|
||||
(current-buffer)))
|
||||
(insert ?\n)
|
||||
(condition-case err
|
||||
(write-region (point-min) (point-max) doom-tutorial-hist-file nil
|
||||
(unless (called-interactively-p 'interactive) 'quiet))
|
||||
(file-error
|
||||
(lwarn '(doom-tutorial-hist-file) :warning "Error writing `%s': %s"
|
||||
doom-tutorial-hist-file (caddr err))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun take-the-tutorial! ()
|
||||
"Tutorial entry point."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue