diff options
| author | Lars Ingebrigtsen | 2020-12-12 13:46:33 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-12-12 13:46:33 +0100 |
| commit | e005095e4130f43c36d75ceac4c3202534f02704 (patch) | |
| tree | 50639ca0b7be0fdee89e619ea806adad0addc824 /lisp/tutorial.el | |
| parent | ad0bbcd565743635a9c9a8dae176c7d38c532ef8 (diff) | |
| download | emacs-e005095e4130f43c36d75ceac4c3202534f02704.tar.gz emacs-e005095e4130f43c36d75ceac4c3202534f02704.zip | |
Offer to save tutorial position on Emacs exit
* lisp/tutorial.el (tutorial--buffer): New variable (bug#27998).
(tutorial--save-on-kill): Use it.
(help-with-tutorial): Set it and add new function to
kill-emacs-query-functions.
Diffstat (limited to 'lisp/tutorial.el')
| -rw-r--r-- | lisp/tutorial.el | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/tutorial.el b/lisp/tutorial.el index d07737e3332..ca84f86f289 100644 --- a/lisp/tutorial.el +++ b/lisp/tutorial.el | |||
| @@ -50,6 +50,9 @@ | |||
| 50 | "Tutorial language.") | 50 | "Tutorial language.") |
| 51 | (make-variable-buffer-local 'tutorial--lang) | 51 | (make-variable-buffer-local 'tutorial--lang) |
| 52 | 52 | ||
| 53 | (defvar tutorial--buffer nil | ||
| 54 | "The selected tutorial buffer.") | ||
| 55 | |||
| 53 | (defun tutorial--describe-nonstandard-key (value) | 56 | (defun tutorial--describe-nonstandard-key (value) |
| 54 | "Give more information about a changed key binding. | 57 | "Give more information about a changed key binding. |
| 55 | This is used in `help-with-tutorial'. The information includes | 58 | This is used in `help-with-tutorial'. The information includes |
| @@ -655,6 +658,15 @@ with some explanatory links." | |||
| 655 | (unless (eq prop-val 'key-sequence) | 658 | (unless (eq prop-val 'key-sequence) |
| 656 | (delete-region prop-start prop-end)))))) | 659 | (delete-region prop-start prop-end)))))) |
| 657 | 660 | ||
| 661 | (defun tutorial--save-on-kill () | ||
| 662 | "Query the user about saving the tutorial when killing Emacs." | ||
| 663 | (when (buffer-live-p tutorial--buffer) | ||
| 664 | (with-current-buffer tutorial--buffer | ||
| 665 | (if (y-or-n-p "Save your position in the tutorial? ") | ||
| 666 | (tutorial--save-tutorial-to (tutorial--saved-file)) | ||
| 667 | (message "Tutorial position not saved")))) | ||
| 668 | t) | ||
| 669 | |||
| 658 | (defun tutorial--save-tutorial () | 670 | (defun tutorial--save-tutorial () |
| 659 | "Save the tutorial buffer. | 671 | "Save the tutorial buffer. |
| 660 | This saves the part of the tutorial before and after the area | 672 | This saves the part of the tutorial before and after the area |
| @@ -802,6 +814,7 @@ Run the Viper tutorial? ")) | |||
| 802 | ;; (Re)build the tutorial buffer if it is not ok | 814 | ;; (Re)build the tutorial buffer if it is not ok |
| 803 | (unless old-tut-is-ok | 815 | (unless old-tut-is-ok |
| 804 | (switch-to-buffer (get-buffer-create tut-buf-name)) | 816 | (switch-to-buffer (get-buffer-create tut-buf-name)) |
| 817 | (setq tutorial--buffer (current-buffer)) | ||
| 805 | ;; (unless old-tut-buf (text-mode)) | 818 | ;; (unless old-tut-buf (text-mode)) |
| 806 | (unless lang (error "Variable lang is nil")) | 819 | (unless lang (error "Variable lang is nil")) |
| 807 | (setq tutorial--lang lang) | 820 | (setq tutorial--lang lang) |
| @@ -814,6 +827,7 @@ Run the Viper tutorial? ")) | |||
| 814 | ;; a hook to save it when the buffer is killed. | 827 | ;; a hook to save it when the buffer is killed. |
| 815 | (setq buffer-auto-save-file-name nil) | 828 | (setq buffer-auto-save-file-name nil) |
| 816 | (add-hook 'kill-buffer-hook 'tutorial--save-tutorial nil t) | 829 | (add-hook 'kill-buffer-hook 'tutorial--save-tutorial nil t) |
| 830 | (add-hook 'kill-emacs-query-functions 'tutorial--save-on-kill) | ||
| 817 | 831 | ||
| 818 | ;; Insert the tutorial. First offer to resume last tutorial | 832 | ;; Insert the tutorial. First offer to resume last tutorial |
| 819 | ;; editing session. | 833 | ;; editing session. |