Subject: bug#74364: Bug?

From: Manuel Giraud <[email-masked]>
Date: Fri, 29 Nov 2024 16:46:55 +0100

Eli Zaretskii <[email-masked]> writes:

>> From: Manuel Giraud <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Tue, 26 Nov 2024 19:43:04 +0100
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > So my suggestion would be to modify tutorial--save-tutorial and
>> > tutorial--save-on-kill such that of tutorial--lang is nil, they will
>> > do nothing.  Because there's no point of trying to save the tutorial
>> > in that case.
>> 
>> I could try to come up with a patch like this.
>
> Please do, and thanks.

What about this?  I have mimic it after your patch dec2ac0c657.  I've
tested it lightly and it seems to work as expected:

                   - The user can save the TUTORIAL to a file
                   
                   - Trying to kill Emacs will ask if the user wants to
                     save his progression.

                   - The progression is correctly saved.
                   
>From 407fbd578a171dbd746d6ee62d8c1e40c772978e Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Fri, 29 Nov 2024 16:35:47 +0100
Subject: [PATCH] Fix exiting Emacs after saving a tutorial

* lisp/tutorial.el (tutorial--lang)
(tutorial--point-before-chkeys): Add both variables as
permanent-local, so that saving the tutorial to some file
doesn't kill these buffer-local variables.  Otherwise, trying to
exit Emacs after saving the tutorial will signal an error,
because 'tutorial--lang' is nil.  (Bug#74364)
---
 lisp/tutorial.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/tutorial.el b/lisp/tutorial.el
index d754db238de..86537d995fe 100644
--- a/lisp/tutorial.el
+++ b/lisp/tutorial.el
@@ -650,7 +650,12 @@ tutorial--remove-remarks
 	  (delete-region prop-start prop-end))))))
 
 (defvar tutorial--starting-point)
+
+;; For when the user saves the TUTORIAL to a file.
 (put 'tutorial--starting-point 'permanent-local t)
+(put 'tutorial--lang 'permanent-local t)
+(put 'tutorial--point-before-chkeys 'permanent-local t)
+
 (defun tutorial--save-on-kill ()
   "Query the user about saving the tutorial when killing Emacs."
   (when (buffer-live-p tutorial--buffer)
-- 
2.47.0

-- 
Manuel Giraud