From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes Date: Sun, 20 Feb 2022 20:04:31 +0100 Message-ID: <87ley5iclc.fsf@aol.com> References: <87ley5iclc.fsf.ref@aol.com> Reply-To: Ergus Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34058"; mail-complaints-to="usenet@ciao.gmane.io" To: 54074@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 20 20:06:23 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 1nLrXJ-0008dv-S2 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Feb 2022 20:06:21 +0100 Original-Received: from localhost ([::1]:41300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLrXI-00014H-At for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Feb 2022 14:06:20 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLrX0-000148-Jt for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:06:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLrX0-0003FV-94 for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nLrX0-00051U-5P for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Feb 2022 19:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54074 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.164538392319254 (code B ref -1); Sun, 20 Feb 2022 19:06:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Feb 2022 19:05:23 +0000 Original-Received: from localhost ([127.0.0.1]:33755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLrWM-00050P-Vx for submit@debbugs.gnu.org; Sun, 20 Feb 2022 14:05:23 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:48568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLrWL-00050H-AM for submit@debbugs.gnu.org; Sun, 20 Feb 2022 14:05:21 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLrWL-00012F-5c for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:05:21 -0500 Original-Received: from sonic303-3.consmr.mail.bf2.yahoo.com ([74.6.131.42]:46399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLrWH-00032O-NF for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:05:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1645383916; bh=lXDhdOW3jYzOqMgyder1NIeUjGWfGKL7UnokuWL/jdo=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=qjx5j7Udl0oa+nyI6x1vxN6fChD3gQOQTcNFB+z7m4q2Sim2IiNSZpEipEt6s4cCra8gUzWdaejQ7IPQ4+8S2fJxqvdg3x7eaqD46WiZAdMOzqTL93yoTkJ8LnRWtEOhxDodVBMLfVP1KNLVAW9EBa/41O9zMON9tXE8kUJUn29q58e1hRBvEmu7fIk66PgAEMouzIbfvmCZ6yr5RGPKBilP/BMA3Sucw/6LxNpGwpJMdNk5B4qNByLC6oB61Sk1xwwwq9U3vFtaflT/jF1tcKTsLRgJp3FHpbu+ImDexq5lWHHslLAjqikoTbPCZgMCfQi0RKydfy3dIUB1ThUxyA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1645383916; bh=cjTFJVmSxDNzXywffJyKNh/veyae9eKDKF+SozjaNe/=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=BNDaML92riTzXyh4/giUjxcgkjwz8U7fva5GcoVBPEeLDKd1DS/qpvx3g6kHUfC8ywOOyrDPepWmiZcuxQbaUUNi8mFsylZY78l4fuFINXICH+oW7cCxrwOFzU9kTtm+qktviRx01TjlFzhgDDmKdAUsF7hiEvNqjtrv9AgN/xwVgeTmOCRIXDox8L5SPUWmkJve7yOmKtdkDk8ABF1NkwYJLVbolxhkKp46bLivj5Ia4fZCXRJxstGJRYxC0RbpSMQeYbIwlokdxIkDK/e7yfo9/Zc0LgyrgZ7xQLLnivm4kRHG6+lprO6mUhQ/v8Ge7HyDm0mJ8R60n8lGDW2dlA== X-YMail-OSG: Lnga1scVM1l9XW1KEw1J3aLXjhSM6FWIrrthGy5q0T0Z47FVTMFSEwGYcHGwTN7 ebvRiy8MDhJNSMLf28XDdHhbh5jRXsYrnsE2seT_UnX.BTwiusZM13NPJGsUWE4yOC8chlca8v7l Bns8qc_cp6W5bZpRjYex7ivRTLXVd3D76cOs9sd4xO026De7JpSt06G59.wNnQASh3HzX6XmToti 2R6njLsAXryG0UlNrqX0JCHOovfPHQfFel.qUaNoX_YraQ22VbTNhWzxUk4Cc47FZlIehs4YOfZF CId1YaAAAGiZDKifpVEZSIHtlye6_JA3Ce8KwIqtGOoymRC.HjL8BiclfSwBAGEt2rjG_JOpgMb6 fTfBxjtYbmcNfXwy.LcYiLbotrCZ.tYtD1wqylh4CHVcLajrf4jI3jt9.m6ULGCUCY3GRHbpNbqj i6mhUcK2RarteVrHw7.NI7fGkLCRajaTyM24GR_GeoCv0Uyvq0mBIstFPHvmdiTewRBte_N7RqXk 78_Os37ysuZZjLe6ys0qASk6sN4_wS2gGIxaZoqZlJgEJgWLqe9SpNoJbUZaGNsTbMNIZjL1vYIn 2TAoiw3_iUWVZJo3va0vA1Wq_FH19VCnffAnkIYZZEVQiSvIfNih0MTYtGPM5nbcXywq1BIJxUbf _v8oRWs9sZw6nvuuIQQJkHorTqd1L2vF7CqnHU8rfSmAi5rlYOTHUL1du7osQ4GIEOQq4EgxWM9M Z75ytzDdwjjTdqNPHh73vjuLNt3xKvYOFPSIvE5yIPNRaFsrFiVXtom9Q35EIjiajs.qYg.jMrmJ Gu54GKjwyKE.Ig5b7Mc_8w1Pmu9U673M7UAkIwN_LD X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.bf2.yahoo.com with HTTP; Sun, 20 Feb 2022 19:05:16 +0000 Original-Received: by kubenode509.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID a2dee42e35594a6af7d2b6c95d187430; Sun, 20 Feb 2022 19:05:13 +0000 (UTC) X-Mailer: WebService/1.1.19797 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.131.42; envelope-from=spacibba@aol.com; helo=sonic303-3.consmr.mail.bf2.yahoo.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:227266 Archived-At: Hi: 1) Recently I have seen that many packages have a pattern where a global minor mode adds a set of keybindings to another (like isearch or minibuffer). The issue comes when they want to disable the mode, because sometimes they need to iterate or loop over, and then emacs looses the previous binding unless they also adds more code to remember it when set and then bring it back when unset. So far with nested keymaps this could be solved, but there is not any clean way to do that; so my request is to extend the new keymap-set to set keymap without a prefix in another... The idea is more or less to enable the developers of packages to do something like: ``` (defvar-keymap my-mode-isearch-map ...) (define-minor-mode my-mode :global t (if my-mode (keymap-set isearch-mode-map my-mode-isearch-map) (keymap-unset isearch-mode-map ))) ``` With that then could be trivial to implemented something like use-packages :bind, so (define-minor-mode my-mode :global t :keymap (my-mode-map :map isearch-mode-map my-mode-isearch-map)) or similar... I am wondering how nobody have requested this before, when it is a very common issue I find in many packages around. 2) Something similar happens to some variables that are modified in minor modes and then should be restored... this forces sometimes to restart emacs... (for example completion-styles in fido-mode or some hooks that are always added and then need to be removed... all these is very mechanic and increases code and sources of errors...). The best approach for this one is to save the original value in an alist and assign with a wrapper around setq... and use a loop when disabling the mode to restore the original values.... it is not perfect, but works in many cases... To restore the original value they check if the current vars's value is the same that was set (to assert it was not changed latter). This way if I try fido-mode and I don't like it, then not restart is needed to assert that completion-styles is what I had before... Maybe we could consider to add some api for these functionalities... Does it makes sense?? In GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4) of 2022-02-20 built on Ergus Repository revision: e6f541f2383cf860c6a2d6c8d366c21a3b8de2d0 Repository branch: master System Description: Arch Linux Configured using: 'configure --prefix=/home/ergo/.local/ --with-mailutils --with-json --with-x-toolkit=gtk3 --with-xft --with-wide-int --with-modules --with-cairo --with-harfbuzz --with-native-compilation --with-pgtk' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP XIM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: electric-pair-mode: t global-auto-revert-mode: t xclip-mode: t flyspell-mode: t company-mode: t flycheck-mode: t diff-hl-margin-mode: t composable-mark-mode: t composable-mode: t repeat-mode: t xterm-mouse-mode: t my/consult-mode: t vertico-mouse-mode: t vertico-mode: t minibuffer-depth-indicate-mode: t winner-mode: t save-place-mode: t delete-selection-mode: t savehist-mode: t global-display-fill-column-indicator-mode: t display-fill-column-indicator-mode: t global-display-line-numbers-mode: t display-line-numbers-mode: t which-key-mode: t override-global-mode: t eldoc-mode: t show-paren-mode: t mouse-wheel-mode: t file-name-shadow-mode: t context-menu-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t column-number-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t Load-path shadows: ~/gits/emacs_clones/composable/composable-mark hides /home/ergo/.config/emacs/elpa/composable-20201024.1458/composable-mark ~/gits/emacs_clones/composable/composable hides /home/ergo/.config/emacs/elpa/composable-20201024.1458/composable /home/ergo/.config/emacs/elpa/transient-20220216.2303/transient hides /home/ergo/.local/share/emacs/29.0.50/lisp/transient Features: (shadow sort mail-extr emacsbug message mailcap yank-media rmc puny rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils vertico-directory elec-pair autorevert filenotify xclip flyspell-correct flyspell ispell company-semantic company-template company-capf company flycheck ansi-color json map find-func dash pcase diff-hl-margin diff-hl-dired advice dired-x dired dired-loaddefs diff-hl log-view pcvs-util vc-dir ewoc vc vc-dispatcher diff-mode vertico-repeat cape comp comp-cstr warnings term/tmux term/xterm xterm init composable composable-mark repeat xt-mouse simple-16-theme edmacro kmacro vertico-mouse vertico mb-depth winner ring saveplace delsel savehist display-fill-column-indicator display-line-numbers diminish which-key cl-extra help-mode use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key easy-mmode use-package-core disp-table info ede/auto eieio-base cl-seq eieio seq subr-x byte-opt bytecomp byte-compile cconv eieio-core cl-macs gv eieio-loaddefs cl-loaddefs cl-lib tex-site rx slime-autoloads early-init iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 198940 54047) (symbols 48 15486 0) (strings 32 59909 31324) (string-bytes 1 2103818) (vectors 16 30201) (vector-slots 8 452967 284466) (floats 8 109 1121) (intervals 56 726 0) (buffers 992 11))