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

From: Visuwesh <[email-masked]>
Date: Mon, 10 Oct 2022 21:29:03 +0530

[திங்கள் அக்டோபர் 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)))