From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel Subject: [WIP PATCH] Adding keys to keymaps in alphabetical order (for use with `mode-line-mode-menu') Date: Thu, 17 Jun 2021 20:39:42 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000008fc51d05c50213f0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7925"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 18 05:41:11 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lu5NX-0001s2-6N for ged-emacs-devel@m.gmane-mx.org; Fri, 18 Jun 2021 05:41:11 +0200 Original-Received: from localhost ([::1]:53336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lu5NQ-00038f-8m for ged-emacs-devel@m.gmane-mx.org; Thu, 17 Jun 2021 23:41:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lu5MJ-0002Rl-Jm for emacs-devel@gnu.org; Thu, 17 Jun 2021 23:39:55 -0400 Original-Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:35507) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lu5MH-0001w6-Vj for emacs-devel@gnu.org; Thu, 17 Jun 2021 23:39:55 -0400 Original-Received: by mail-pl1-x629.google.com with SMTP id x19so3994452pln.2 for ; Thu, 17 Jun 2021 20:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=wZLvLvHvPZcL3hWoL0Yy41MBdLCujvbOsCPTjoIRvWo=; b=cbgeGYtNKoUVba3lkypv/6XDmSBnwDW6BZwmx4LDNBogE/ERO3km9xMtTWbeD6zEw7 yWGi5ByxJ/dQWb3DPMuAKkptHuRKhiXK2H7YfcFVXcX+zuLwQ58cR9auG8TKXc52lQnP V/926Yp8oAVqRrJ5qdvXu/r4MbFV70BmFg1fj/oBXfuadTCzkwXiFXpdsm4OK3LmXMmG yuf998i7VByI+cYJLYdBYAAGJGoQU2gldUxIUAnQFqlQNadSuqxGcEggPkj5oOE1zbMV yNsHDO5jzoCX88ZyU+PrWEfS7iNHB7BE9fUeqcQADaRZobt5ALwEHQzP6gQUNmc9zKF5 0Xdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wZLvLvHvPZcL3hWoL0Yy41MBdLCujvbOsCPTjoIRvWo=; b=jKiSnRL8xPYgyXH0NJhjiZtynwuASJwThOyb1Q2J1UDUHEBrfML7uE//eW2biudsAZ pAoZ9VA/ym+4BuVhXkxSkJTCsPzUJXfdNCDcHcO2V3kwJnZNyp0jgPP2J6H/MZJsjLRq w44zpdQVfk8PpL2BQmn1prJbDWYF3rRSd7Bc5kNkx9dDW3AASXZkHqN4eCuudBMgTwig ouM21fA0M1ZfmGhfI4QpDKDGJNDp5X1HgRxn+POpOzWWmdKdYGyYdWLgqQ63qiqOE/aP W6zKKKhx6k08VJl8DEFl/35YcN74lv3ZVPxMLObo+IgsJgTsgXDHIhGWEbg+uS/cEqcV xEQQ== X-Gm-Message-State: AOAM532URtHPvw0PJvuznaUU8KGh/Jg5jGOIlIFgxmrmGAWmsHqBEkX0 nJn2YN1XIRadipPiG4rJPMbQXCLfGyhG+nYQdBgGYUNVcJ4= X-Google-Smtp-Source: ABdhPJz5krWqzjf1a99I4GxCd9g2Zs3XvylZjwjOqWkKzBD2sx6xxceQfPHpgQn+AT0gUjro0w8c/VhjFcMTOoAtHHc= X-Received: by 2002:a17:902:e810:b029:121:94ea:909c with SMTP id u16-20020a170902e810b029012194ea909cmr611880plg.17.1623987592311; Thu, 17 Jun 2021 20:39:52 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=jporterbugs@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270899 Archived-At: --0000000000008fc51d05c50213f0 Content-Type: text/plain; charset="UTF-8" Currently, there's not a simple way of inserting a key binding into a keymap in alphabetical order. This would be nice for `mode-line-mode-menu'; to see the issue, you can run the following: emacs -Q ;; on the mode name in the mode-line ;; See the nice alphabetical list M-x ruler-mode ;; on the mode name in the mode-line again ;; "Ruler" is first(?!) I believe `ruler-mode' is the only place in Emacs itself that has this issue, but third-party packages (or user configs) might want to add to `mode-line-mode-menu'. For example, I prefer to get rid of the mode-line lighter for `company-mode' and put an item for it into `mode-line-mode-menu' for the rare times I want to check/change its status. Especially with packages that get loaded after startup, the current behavior could be somewhat confusing since the order items are added to the menu can vary. I've attached a simple patch that fixes this by adding a `define-key-sorted' function. I imagine it still needs some work to handle more complex cases, but it works well enough for `mode-line-mode-menu'. - Jim --0000000000008fc51d05c50213f0 Content-Type: application/octet-stream; name="0001-Add-define-key-sorted-to-simplify-entering-menu-item.patch" Content-Disposition: attachment; filename="0001-Add-define-key-sorted-to-simplify-entering-menu-item.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kq1s9p350 RnJvbSA4ODBhODNjNjYxYmFmZjY4OTBlMGJhNmZjYjYwNmQ0MjhhOTJiMjI2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBKaW0gUG9ydGVyIDxqcG9ydGVyYnVnc0BnbWFpbC5jb20+CkRh dGU6IFRodSwgMTcgSnVuIDIwMjEgMjA6Mzg6NDcgLTA3MDAKU3ViamVjdDogW1BBVENIXSBBZGQg J2RlZmluZS1rZXktc29ydGVkJyB0byBzaW1wbGlmeSBlbnRlcmluZyBtZW51IGl0ZW1zIGluCiBh bHBoYWJldGljYWwgb3JkZXIKCiogbGlzcC9zdWJyLmVsIChkZWZpbmUta2V5LXNvcnRlZCk6IE5l dyBmdW5jdGlvbi4KKiBsaXNwL3J1bGVyLW1vZGUuZWw6IFVzZSAnZGVmaW5lLWtleS1zb3J0ZWQn IGluc3RlYWQgb2YgJ2RlZmluZS1rZXknLgotLS0KIGxpc3AvcnVsZXItbW9kZS5lbCB8ICAyICst CiBsaXNwL3N1YnIuZWwgICAgICAgfCAyMCArKysrKysrKysrKysrKysrKysrKwogMiBmaWxlcyBj aGFuZ2VkLCAyMSBpbnNlcnRpb25zKCspLCAxIGRlbGV0aW9uKC0pCgpkaWZmIC0tZ2l0IGEvbGlz cC9ydWxlci1tb2RlLmVsIGIvbGlzcC9ydWxlci1tb2RlLmVsCmluZGV4IGEwZDRmNmU5NmMuLmFi YTI3OTMwZGIgMTAwNjQ0Ci0tLSBhL2xpc3AvcnVsZXItbW9kZS5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tIAoyLjI1LjEKCg== --0000000000008fc51d05c50213f0--