GNU bug report logs - #79136
[PATCH] Inhibit warning for missing lexbind cookie in kkc init file

Previous Next

Package: emacs;

Reported by: Sean Devlin <spd <at> toadstyle.org>

Date: Thu, 31 Jul 2025 18:22:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

To reply to this bug, email your comments to 79136 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79136; Package emacs. (Thu, 31 Jul 2025 18:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sean Devlin <spd <at> toadstyle.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 31 Jul 2025 18:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Inhibit warning for missing lexbind cookie in kkc init file
Date: Thu, 31 Jul 2025 13:21:07 -0500
[Message part 1 (text/plain, inline)]
Hi folks,

This change is to suppress a warning for a missing lexical-binding
cookie in the kkcrc file used by the Japanese input method. Emacs
generates this file, and AFAICT it is not meant to be edited by users.

To reproduce the warning:

1. mkdir /tmp/emacs-kkcrc
2. HOME=/tmp/emacs-kkcrc emacs
3. q                            > Dismiss the start screen
4. C-\ japanese RET
5. nihongo SPC RET              > Enter some Japanese text
6. C-x C-c
7. Repeat steps 2-5

On the second iteration of step 5, you should seen a warning message
when Emacs loads the kkcrc file.

I looked at how this was handled elsewhere and made the attached patch.

Please let me know if anything else is required.

Thanks!


In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.6.0, NS
appkit-2575.70 Version 15.6 (Build 24G5065c)) of 2025-07-16 built on
beatrix.local
Repository revision: 087a11d1372d02bd45c1efbcf2fc7e5a98ddf1e5
Repository branch: spd-igc
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.6

Configured using:
'configure --with-ns --with-modules --with-native-compilation
--with-libgmp --with-tree-sitter --with-sqlite3 --with-mps=yes
--without-imagemagick --without-dbus CPPFLAGS=-I/opt/homebrew/include
LDFLAGS=-L/opt/homebrew/lib PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig
ac_cv_func_posix_spawn_file_actions_addchdir=no'

[0001-Inhibit-warning-for-missing-lexbind-cookie-in-kkc-in.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79136; Package emacs. (Sat, 02 Aug 2025 09:09:02 GMT) Full text and rfc822 format available.

Message #8 received at 79136 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 79136 <at> debbugs.gnu.org
Subject: Re: bug#79136: [PATCH] Inhibit warning for missing lexbind cookie in
 kkc init file
Date: Sat, 02 Aug 2025 12:08:03 +0300
> From: Sean Devlin <spd <at> toadstyle.org>
> Date: Thu, 31 Jul 2025 13:21:07 -0500
> 
> This change is to suppress a warning for a missing lexical-binding
> cookie in the kkcrc file used by the Japanese input method. Emacs
> generates this file, and AFAICT it is not meant to be edited by users.
> 
> To reproduce the warning:
> 
> 1. mkdir /tmp/emacs-kkcrc
> 2. HOME=/tmp/emacs-kkcrc emacs
> 3. q                            > Dismiss the start screen
> 4. C-\ japanese RET
> 5. nihongo SPC RET              > Enter some Japanese text
> 6. C-x C-c
> 7. Repeat steps 2-5
> 
> On the second iteration of step 5, you should seen a warning message
> when Emacs loads the kkcrc file.
> 
> I looked at how this was handled elsewhere and made the attached patch.

Thanks.  The patch you send was almost okay, but we want in addition
to make sure this file does have the cookie when written by Emacs 31
and later.  So please see if the alternative patch below gives good
results.

diff --git a/lisp/international/kkc.el b/lisp/international/kkc.el
index 6d603cf..9abf35f 100644
--- a/lisp/international/kkc.el
+++ b/lisp/international/kkc.el
@@ -64,9 +64,12 @@ kkc-save-init-file
 	   (not (eq kkc-init-file-flag t)))
       (let ((coding-system-for-write 'iso-2022-7bit)
 	    (print-length nil))
-	(write-region (format "(setq kkc-lookup-cache '%S)\n" kkc-lookup-cache)
-		      nil
-		      kkc-init-file-name))))
+	(write-region
+         (format
+          "-*- lexical-binding: t; -*-\n\n(setq kkc-lookup-cache '%S)\n"
+          kkc-lookup-cache)
+	 nil
+	 kkc-init-file-name))))
 
 ;; Sequence of characters to be used for indexes for shown list.  The
 ;; Nth character is for the Nth conversion in the list currently shown.
@@ -178,7 +181,8 @@ kkc-lookup-key
     (add-hook 'kill-emacs-hook 'kkc-save-init-file)
     (if (file-readable-p kkc-init-file-name)
 	(condition-case nil
-	    (load-file kkc-init-file-name)
+            (let ((warning-inhibit-types '((files missing-lexbind-cookie))))
+	      (load-file kkc-init-file-name))
 	  (kkc-error "Invalid data in %s" kkc-init-file-name))))
   (or (and (nested-alist-p kkc-lookup-cache)
 	   (eq (car kkc-lookup-cache) kkc-lookup-cache-tag))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79136; Package emacs. (Sat, 02 Aug 2025 14:05:01 GMT) Full text and rfc822 format available.

Message #11 received at 79136 <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79136 <at> debbugs.gnu.org
Subject: Re: bug#79136: [PATCH] Inhibit warning for missing lexbind cookie in
 kkc init file
Date: Sat, 2 Aug 2025 09:03:53 -0500
[Message part 1 (text/plain, inline)]
> On Aug 2, 2025, at 4:08 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Sean Devlin <spd <at> toadstyle.org>
>> Date: Thu, 31 Jul 2025 13:21:07 -0500
>> 
>> This change is to suppress a warning for a missing lexical-binding
>> cookie in the kkcrc file used by the Japanese input method. Emacs
>> generates this file, and AFAICT it is not meant to be edited by users.
>> 
>> To reproduce the warning:
>> 
>> 1. mkdir /tmp/emacs-kkcrc
>> 2. HOME=/tmp/emacs-kkcrc emacs
>> 3. q                            > Dismiss the start screen
>> 4. C-\ japanese RET
>> 5. nihongo SPC RET              > Enter some Japanese text
>> 6. C-x C-c
>> 7. Repeat steps 2-5
>> 
>> On the second iteration of step 5, you should seen a warning message
>> when Emacs loads the kkcrc file.
>> 
>> I looked at how this was handled elsewhere and made the attached patch.
> 
> Thanks.  The patch you send was almost okay, but we want in addition
> to make sure this file does have the cookie when written by Emacs 31
> and later.  So please see if the alternative patch below gives good
> results.
> 
> diff --git a/lisp/international/kkc.el b/lisp/international/kkc.el
> index 6d603cf..9abf35f 100644
> --- a/lisp/international/kkc.el
> +++ b/lisp/international/kkc.el
> @@ -64,9 +64,12 @@ kkc-save-init-file
> 	   (not (eq kkc-init-file-flag t)))
>       (let ((coding-system-for-write 'iso-2022-7bit)
> 	    (print-length nil))
> -	(write-region (format "(setq kkc-lookup-cache '%S)\n" kkc-lookup-cache)
> -		      nil
> -		      kkc-init-file-name))))
> +	(write-region
> +         (format
> +          "-*- lexical-binding: t; -*-\n\n(setq kkc-lookup-cache '%S)\n"
> +          kkc-lookup-cache)
> +	 nil
> +	 kkc-init-file-name))))
> 
> ;; Sequence of characters to be used for indexes for shown list.  The
> ;; Nth character is for the Nth conversion in the list currently shown.
> @@ -178,7 +181,8 @@ kkc-lookup-key
>     (add-hook 'kill-emacs-hook 'kkc-save-init-file)
>     (if (file-readable-p kkc-init-file-name)
> 	(condition-case nil
> -	    (load-file kkc-init-file-name)
> +            (let ((warning-inhibit-types '((files missing-lexbind-cookie))))
> +	      (load-file kkc-init-file-name))
> 	  (kkc-error "Invalid data in %s" kkc-init-file-name))))
>   (or (and (nested-alist-p kkc-lookup-cache)
> 	   (eq (car kkc-lookup-cache) kkc-lookup-cache-tag))

Thanks Eli.

I tried this patch, but there was an error reading the kkcrc file. The file-local
property line is missing a comment at the beginning. See if the attached patch
works. (I also split up the string formatting to make it more readable to me, but
feel free to change it back if you prefer a single function call.)

Cheers.

[0001-Inhibit-warning-for-missing-lexbind-cookie-in-kkc-in.patch (application/octet-stream, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 02 Aug 2025 15:02:02 GMT) Full text and rfc822 format available.

Notification sent to Sean Devlin <spd <at> toadstyle.org>:
bug acknowledged by developer. (Sat, 02 Aug 2025 15:02:02 GMT) Full text and rfc822 format available.

Message #16 received at 79136-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 79136-done <at> debbugs.gnu.org
Subject: Re: bug#79136: [PATCH] Inhibit warning for missing lexbind cookie in
 kkc init file
Date: Sat, 02 Aug 2025 18:01:26 +0300
> From: Sean Devlin <spd <at> toadstyle.org>
> Date: Sat, 2 Aug 2025 09:03:53 -0500
> Cc: 79136 <at> debbugs.gnu.org
> 
> I tried this patch, but there was an error reading the kkcrc file. The file-local
> property line is missing a comment at the beginning. See if the attached patch
> works. (I also split up the string formatting to make it more readable to me, but
> feel free to change it back if you prefer a single function call.)

Thanks, fixed the missing semicolons and installed the change on the
master branch.

I'm therefore closing the bug.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79136; Package emacs. (Sat, 02 Aug 2025 15:06:01 GMT) Full text and rfc822 format available.

Message #19 received at 79136-done <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79136-done <at> debbugs.gnu.org
Subject: Re: bug#79136: [PATCH] Inhibit warning for missing lexbind cookie in
 kkc init file
Date: Sat, 2 Aug 2025 10:05:10 -0500

> On Aug 2, 2025, at 10:01 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Sean Devlin <spd <at> toadstyle.org>
>> Date: Sat, 2 Aug 2025 09:03:53 -0500
>> Cc: 79136 <at> debbugs.gnu.org
>> 
>> I tried this patch, but there was an error reading the kkcrc file. The file-local
>> property line is missing a comment at the beginning. See if the attached patch
>> works. (I also split up the string formatting to make it more readable to me, but
>> feel free to change it back if you prefer a single function call.)
> 
> Thanks, fixed the missing semicolons and installed the change on the
> master branch.
> 
> I'm therefore closing the bug.

Sounds good, thank you!



This bug report was last modified 12 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.