[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e005095: Offer to save tutorial position on Emacs exit
From: |
Lars Ingebrigtsen |
Subject: |
master e005095: Offer to save tutorial position on Emacs exit |
Date: |
Sat, 12 Dec 2020 07:47:17 -0500 (EST) |
branch: master
commit e005095e4130f43c36d75ceac4c3202534f02704
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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.
---
lisp/tutorial.el | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lisp/tutorial.el b/lisp/tutorial.el
index d07737e..ca84f86 100644
--- a/lisp/tutorial.el
+++ b/lisp/tutorial.el
@@ -50,6 +50,9 @@
"Tutorial language.")
(make-variable-buffer-local 'tutorial--lang)
+(defvar tutorial--buffer nil
+ "The selected tutorial buffer.")
+
(defun tutorial--describe-nonstandard-key (value)
"Give more information about a changed key binding.
This is used in `help-with-tutorial'. The information includes
@@ -655,6 +658,15 @@ with some explanatory links."
(unless (eq prop-val 'key-sequence)
(delete-region prop-start prop-end))))))
+(defun tutorial--save-on-kill ()
+ "Query the user about saving the tutorial when killing Emacs."
+ (when (buffer-live-p tutorial--buffer)
+ (with-current-buffer tutorial--buffer
+ (if (y-or-n-p "Save your position in the tutorial? ")
+ (tutorial--save-tutorial-to (tutorial--saved-file))
+ (message "Tutorial position not saved"))))
+ t)
+
(defun tutorial--save-tutorial ()
"Save the tutorial buffer.
This saves the part of the tutorial before and after the area
@@ -802,6 +814,7 @@ Run the Viper tutorial? "))
;; (Re)build the tutorial buffer if it is not ok
(unless old-tut-is-ok
(switch-to-buffer (get-buffer-create tut-buf-name))
+ (setq tutorial--buffer (current-buffer))
;; (unless old-tut-buf (text-mode))
(unless lang (error "Variable lang is nil"))
(setq tutorial--lang lang)
@@ -814,6 +827,7 @@ Run the Viper tutorial? "))
;; a hook to save it when the buffer is killed.
(setq buffer-auto-save-file-name nil)
(add-hook 'kill-buffer-hook 'tutorial--save-tutorial nil t)
+ (add-hook 'kill-emacs-query-functions 'tutorial--save-on-kill)
;; Insert the tutorial. First offer to resume last tutorial
;; editing session.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master e005095: Offer to save tutorial position on Emacs exit,
Lars Ingebrigtsen <=