From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#58376: [PATCH] Set the PARENTS argument for language environments Date: Sun, 09 Oct 2022 21:00:24 +0530 Message-ID: <87o7ulovzj.fsf@gmail.com> References: <83wn9ajrud.fsf@gnu.org> <83tu4eji4l.fsf@gnu.org> <83edvhjt76.fsf@gnu.org> <838rlpjfmr.fsf@gnu.org> <87wn99oxtv.fsf@gmail.com> <87sfjxox3r.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27039"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: =?UTF-8?Q?=E0=A4=B8=E0=A4=AE=E0=A5=80=E0=A4=B0_?= =?UTF-8?Q?=E0=A4=B8=E0=A4=BF=E0=A4=82=E0=A4=B9?= Sameer Singh , 58376@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 09 17:32:10 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ohYHh-0006sS-Fg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Oct 2022 17:32:09 +0200 Original-Received: from localhost ([::1]:47052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohYHg-0001fI-48 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Oct 2022 11:32:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohYGd-0000yd-Jo for bug-gnu-emacs@gnu.org; Sun, 09 Oct 2022 11:31:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohYGd-00026M-AX for bug-gnu-emacs@gnu.org; Sun, 09 Oct 2022 11:31:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ohYGb-0001vs-Ua for bug-gnu-emacs@gnu.org; Sun, 09 Oct 2022 11:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Oct 2022 15:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58376 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58376-submit@debbugs.gnu.org id=B58376.16653294357396 (code B ref 58376); Sun, 09 Oct 2022 15:31:01 +0000 Original-Received: (at 58376) by debbugs.gnu.org; 9 Oct 2022 15:30:35 +0000 Original-Received: from localhost ([127.0.0.1]:44755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohYGB-0001vD-9e for submit@debbugs.gnu.org; Sun, 09 Oct 2022 11:30:35 -0400 Original-Received: from mail-pl1-f196.google.com ([209.85.214.196]:45628) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ohYG9-0001us-MP for 58376@debbugs.gnu.org; Sun, 09 Oct 2022 11:30:34 -0400 Original-Received: by mail-pl1-f196.google.com with SMTP id i6so3390712pli.12 for <58376@debbugs.gnu.org>; Sun, 09 Oct 2022 08:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=8eSEn4u86Yxt9IF13oBnk/KYhxU/6v6e1OSG6pN4i9s=; b=fYarFBODB06c6+v3he9t3NNvgrz+9xHQV2i6i31VySBibyH0eN2rXtI7c2dDsSyZmE KMlFLjCW6UmpaURb+GwPnoduwgq0WH3rJPKcyZQ054QHthy0ssCoW6Ih8yO17bU59Xw4 SpoSEaiTfW2WDyDn6nDYroauKPa/wOAd3N/VjKhnZVvWJWoSnoLK5SFkuAfTdyztY9/Z MdNwVmFXlo3nUzDDKElf6xhocZFxAw6jaKMC5hwYFgAUgjw0so1Uwh9aKSvFKYqg+4I0 pB/FZUfNy+q3tvSioUR1NM8dAWcPvYKLp3gp1oNrNWWiZW4ztBnLji06BtiIENj/KBqZ oMKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8eSEn4u86Yxt9IF13oBnk/KYhxU/6v6e1OSG6pN4i9s=; b=OjryfLEReqUh9mk3LzPsRbqMR+CM+BmZyDNIgMigcYU1WNBm/pJas5UKPobSZJXE4L N81hD05FPxLqp+Air1utX7v8EgHfbTTMwcZOZNL60DF62peXjS2tKP5hVXf9UvNedyC3 ZSp82bdwV2aZlbEo0V4NXRr/5iPBjWjbG9whb3xFbxDhGrUnA7NMmF5VksxHwV0KS+V6 AvdyQmi5QiDYFSfWo0jlyAfvTp7ZGr5Es9uCPl3Dwz8bQFMHkw7aNtEolc90hUEtWBKI e3ys8pC/fmLt4m3YlnuXW2RehEHDnoCvKKQmpcIc0KYU+z0kgEAaPxxfTpdfWpNlMvCv wEEQ== X-Gm-Message-State: ACrzQf3OwnE4Qr5ixFsRd+ZkHH7jZOLQGs5NoUVVOKSynFIgm76yGNkQ ay6QfUOJk658gLtk0Qvwrsg= X-Google-Smtp-Source: AMsMyM4ue8UHorc0tZDngm+gQ2TNniFo4CbKhji/GikFMT01H/wxEKUw3avf9Ld7/k3MhgFHFga7tA== X-Received: by 2002:a17:902:c94e:b0:181:4ab4:179b with SMTP id i14-20020a170902c94e00b001814ab4179bmr6617943pla.126.1665329427889; Sun, 09 Oct 2022 08:30:27 -0700 (PDT) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id x12-20020a170902ec8c00b00178143a728esm4870829plg.275.2022.10.09.08.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Oct 2022 08:30:27 -0700 (PDT) In-Reply-To: <87sfjxox3r.fsf@gmail.com> (Visuwesh's message of "Sun, 09 Oct 2022 20:36:16 +0530") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:244968 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=9E=E0=AE=BE=E0=AE=AF=E0=AE=BF=E0=AE=B1=E0=AF=81 =E0=AE=85=E0=AE=95= =E0=AF=8D=E0=AE=9F=E0=AF=8B=E0=AE=AA=E0=AE=B0=E0=AF=8D 09, 2022] Visuwesh w= rote: >> Attached patch puts the "Kharosthi" item in both Indian and Misc >> submenus without overwriting. >> >> >> >> The problem is that when looping, the variables setup-map and >> describe-map gets outdated and causes the overwrite. The solution I >> came up with was to update them both to their default after each >> iteration. This involved moving the keymap-setting forms to a >> separate >> function. > > Hmm, I seethat the function can be cleaned up further. I will do it > after my dinner. Please find attached. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-set-language-info-alist-when-multiple-PARENTS-ar.patch >From 6e219f98feb19489c82f9bbcc429241131b75c7a Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Sun, 9 Oct 2022 20:59:50 +0530 Subject: [PATCH] Fix set-language-info-alist when multiple PARENTS are given * 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. (bug#58376) --- lisp/international/mule-cmds.el | 84 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 48e5c9aa1f..4ad0d1003b 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" + (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 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)))) + (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.2 --=-=-=--