Subject: Re: bug#58376: [PATCH] Set the PARENTS argument for language environments

From: समीर सिंह Sameer Singh<[email-masked]>
Date: Tue, 11 Oct 2022 00:08:11 +0530

Thanks, it works this way.
I have created a patch for you, if the ones provided by you do not apply.

I have also created a separate patch adding multiple PARENTs to Kharoshthi
and Gothic.

On Mon, Oct 10, 2022 at 9:29 PM Visuwesh <[email-masked]> wrote:

> [திங்கள் அக்டோபர் 10, 2022] समीर सिंह Sameer Singh wrote:
>
> > This one says: "error: corrupt patch at line 8"
> >
> > The previous one said:
> > error: patch failed: lisp/international/mule-cmds.el:1208
> > error: lisp/international/mule-cmds.el: patch does not apply
> >
>
> I have no idea why that is the case, and my network connection is too
> slow to freshly clone the Emacs repo again.  Can you replace the old
> definition of `set-language-info-alist' with the following two forms
> instead?
>
> (defun set-language-info-setup-keymap (lang-env alist describe-map
> setup-map)
>   "Setup menu items for LANG-ENV.
> See `set-language-info-alist' for details of other arguments."
>   (let ((doc (assq 'documentation alist)))
>     (when doc
>       (define-key-after describe-map (vector (intern lang-env))
>         (cons lang-env 'describe-specified-language-support))))
>   (define-key-after setup-map (vector (intern lang-env))
>     (cons lang-env 'setup-specified-language-environment)))
>
> (defun set-language-info-alist (lang-env alist &optional parents)
>   "Store ALIST as the definition of language environment LANG-ENV.
> ALIST is an alist of KEY and INFO values.  See the documentation of
> `language-info-alist' for the meanings of KEY and INFO.
>
> Optional arg PARENTS is a list of parent menu names; it specifies
> where to put this language environment in the
> Describe Language Environment and Set Language Environment menus.
> For example, (\"European\") means to put this language environment
> in the European submenu in each of those two menus."
>   (cond ((symbolp lang-env)
>          (setq lang-env (symbol-name lang-env)))
>         ((stringp lang-env)
>          (setq lang-env (purecopy lang-env))))
>   (if parents
>       (while parents
>         (let (describe-map setup-map parent-symbol parent prompt)
>           (if (symbolp (setq parent-symbol (car parents)))
>               (setq parent (symbol-name parent))
>             (setq parent parent-symbol parent-symbol (intern parent)))
>           (setq describe-map (lookup-key describe-language-environment-map
> (vector parent-symbol)))
>           ;; This prompt string is for define-prefix-command, so
>           ;; that the map it creates will be suitable for a menu.
>           (or describe-map (setq prompt (format "%s Environment" parent)))
>           (unless describe-map
>             (setq describe-map (intern (format
> "describe-%s-environment-map"
>                                                (downcase parent))))
>             (define-prefix-command describe-map nil prompt)
>             (define-key-after describe-language-environment-map (vector
> parent-symbol)
>               (cons parent describe-map)))
>           (setq setup-map (lookup-key setup-language-environment-map
> (vector parent-symbol)))
>           (unless setup-map
>             (setq setup-map (intern (format "setup-%s-environment-map"
>                                             (downcase parent))))
>             (define-prefix-command setup-map nil prompt)
>             (define-key-after setup-language-environment-map (vector
> parent-symbol)
>               (cons parent setup-map)))
>           (setq parents (cdr parents))
>           (set-language-info-setup-keymap lang-env alist (symbol-value
> describe-map) (symbol-value setup-map))))
>     (set-language-info-setup-keymap lang-env alist
>                                     describe-language-environment-map
> setup-language-environment-map))
>   (dolist (elt alist)
>     (set-language-info-internal lang-env (car elt) (cdr elt)))
>   (if (equal lang-env current-language-environment)
>       (set-language-environment lang-env)))
>
From ebb928ca03c5ffd34a815f09825f3d8b40269868 Mon Sep 17 00:00:00 2001
From: Visuwesh <[email-masked]>
Date: Mon, 10 Oct 2022 23:49:06 +0530
Subject: [PATCH] Fix set-language-info-alist when multiple PARENTS are given
 (bug#58376)

* lisp/international/mule-cmds.el (set-language-info-setup-keymap):
Function factored out from...
(set-language-info-alist): ...here.  Do not mess up the keymaps when
multiple parents are given in PARENTS.
---
 lisp/international/mule-cmds.el | 86 ++++++++++++++++-----------------
 1 file changed, 41 insertions(+), 45 deletions(-)

diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 48e5c9aa1f..dfd2e1438e 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -1208,6 +1208,16 @@ set-language-info-internal
 			  (list 'const lang))
 			(sort (mapcar 'car language-info-alist) 'string<))))))
 
+(defun set-language-info-setup-keymap (lang-env alist describe-map setup-map)
+  "Setup menu items for LANG-ENV.
+See `set-language-info-alist' for details of other arguments."
+  (let ((doc (assq 'documentation alist)))
+    (when doc
+      (define-key-after describe-map (vector (intern lang-env))
+	(cons lang-env 'describe-specified-language-support))))
+  (define-key-after setup-map (vector (intern lang-env))
+    (cons lang-env 'setup-specified-language-environment)))
+
 (defun set-language-info-alist (lang-env alist &optional parents)
   "Store ALIST as the definition of language environment LANG-ENV.
 ALIST is an alist of KEY and INFO values.  See the documentation of
@@ -1222,51 +1232,37 @@ set-language-info-alist
 	 (setq lang-env (symbol-name lang-env)))
 	((stringp lang-env)
 	 (setq lang-env (purecopy lang-env))))
-  (let ((describe-map describe-language-environment-map)
-	(setup-map setup-language-environment-map))
-    (if parents
-	(let ((l parents)
-	      map parent-symbol parent prompt)
-	  (while l
-	    (if (symbolp (setq parent-symbol (car l)))
-		(setq parent (symbol-name parent))
-	      (setq parent parent-symbol parent-symbol (intern parent)))
-	    (setq map (lookup-key describe-map (vector parent-symbol)))
-	    ;; This prompt string is for define-prefix-command, so
-	    ;; that the map it creates will be suitable for a menu.
-	    (or map (setq prompt (format "%s Environment" parent)))
-	    (if (not map)
-		(progn
-		  (setq map (intern (format "describe-%s-environment-map"
-					    (downcase parent))))
-		  (define-prefix-command map nil prompt)
-		  (define-key-after describe-map (vector parent-symbol)
-		    (cons parent map))))
-	    (setq describe-map (symbol-value map))
-	    (setq map (lookup-key setup-map (vector parent-symbol)))
-	    (if (not map)
-		(progn
-		  (setq map (intern (format "setup-%s-environment-map"
-					    (downcase parent))))
-		  (define-prefix-command map nil prompt)
-		  (define-key-after setup-map (vector parent-symbol)
-		    (cons parent map))))
-	    (setq setup-map (symbol-value map))
-	    (setq l (cdr l)))))
-
-    ;; Set up menu items for this language env.
-    (let ((doc (assq 'documentation alist)))
-      (when doc
-	(define-key-after describe-map (vector (intern lang-env))
-	  (cons lang-env 'describe-specified-language-support))))
-    (define-key-after setup-map (vector (intern lang-env))
-      (cons lang-env 'setup-specified-language-environment))
-
-    (dolist (elt alist)
-      (set-language-info-internal lang-env (car elt) (cdr elt)))
-
-    (if (equal lang-env current-language-environment)
-	(set-language-environment lang-env))))
+  (if parents
+      (while parents
+	(let (describe-map setup-map parent-symbol parent prompt)
+	  (if (symbolp (setq parent-symbol (car parents)))
+	      (setq parent (symbol-name parent))
+	    (setq parent parent-symbol parent-symbol (intern parent)))
+	  (setq describe-map (lookup-key describe-language-environment-map (vector parent-symbol)))
+	  ;; This prompt string is for define-prefix-command, so
+	  ;; that the map it creates will be suitable for a menu.
+	  (or describe-map (setq prompt (format "%s Environment" parent)))
+	  (unless describe-map
+	    (setq describe-map (intern (format "describe-%s-environment-map"
+					       (downcase parent))))
+	    (define-prefix-command describe-map nil prompt)
+	    (define-key-after describe-language-environment-map (vector parent-symbol)
+	      (cons parent describe-map)))
+	  (setq setup-map (lookup-key setup-language-environment-map (vector parent-symbol)))
+	  (unless setup-map
+	    (setq setup-map (intern (format "setup-%s-environment-map"
+                                            (downcase parent))))
+	    (define-prefix-command setup-map nil prompt)
+	    (define-key-after setup-language-environment-map (vector parent-symbol)
+	      (cons parent setup-map)))
+	  (setq parents (cdr parents))
+          (set-language-info-setup-keymap lang-env alist (symbol-value describe-map) (symbol-value setup-map))))
+    (set-language-info-setup-keymap lang-env alist
+                                    describe-language-environment-map setup-language-environment-map))
+  (dolist (elt alist)
+    (set-language-info-internal lang-env (car elt) (cdr elt)))
+  (if (equal lang-env current-language-environment)
+      (set-language-environment lang-env)))
 
 (defun read-language-name (key prompt &optional default)
   "Read a language environment name which has information for KEY.
-- 
2.37.3

From b6a26326eaf45bd300a2e1ea5886bdf7e09e5224 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E0=A4=B8=E0=A4=AE=E0=A5=80=E0=A4=B0=20=E0=A4=B8=E0=A4=BF?=
 =?UTF-8?q?=E0=A4=82=E0=A4=B9=20Sameer=20Singh?= <[email-masked]>
Date: Mon, 10 Oct 2022 23:52:24 +0530
Subject: [PATCH] Add multiple PARENTs to Kharoshthi and Gothic (bug#58376)

* lisp/language/misc-lang.el ("Kharoshthi"):
Add "Indian".
* lisp/language/misc-lang.el ("Gothic"):
Add "European".

* lisp/leim/quail/misc-lang.el ("gothic"): Fix typo.
---
 lisp/language/misc-lang.el   | 6 ++++--
 lisp/leim/quail/misc-lang.el | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/language/misc-lang.el b/lisp/language/misc-lang.el
index c34017d9b3..d52f402aca 100644
--- a/lisp/language/misc-lang.el
+++ b/lisp/language/misc-lang.el
@@ -253,7 +253,8 @@ egyptian-shape-grouping
 	        (documentation . "\
 Language environment for Gāndhārī, Sanskrit, and other languages
 using the Kharoṣṭhī script."))
- '("Misc"))
+ '("Misc"
+   "Indian"))
 
 (let ((consonant     "[\U00010A00\U00010A10-\U00010A35]")
       (vowel         "[\U00010A01-\U00010A06]")
@@ -322,7 +323,8 @@ egyptian-shape-grouping
             (documentation . "\
 Ancient Gothic language using the Gothic script is supported in this
 language environment."))
- '("Misc"))
+ '("Misc"
+   "European"))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Coptic
diff --git a/lisp/leim/quail/misc-lang.el b/lisp/leim/quail/misc-lang.el
index 73287ee784..e9e11ac679 100644
--- a/lisp/leim/quail/misc-lang.el
+++ b/lisp/leim/quail/misc-lang.el
@@ -1526,7 +1526,7 @@
 
 (quail-define-package
  "gothic" "Gothic" "𐌰" nil
- "Input methid for the ancient Gothic script."
+ "Input method for the ancient Gothic script."
  nil t t t t nil nil nil nil nil t)
 
 (quail-define-rules
-- 
2.37.3