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 22:18:07 +0100 Message-ID: References: <87ley5iclc.fsf.ref@aol.com> <87ley5iclc.fsf@aol.com> <87czjhmior.fsf@gnus.org> Reply-To: Ergus Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20660"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 54074@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 20 22:19:22 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 1nLtc2-00057h-4b for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Feb 2022 22:19:22 +0100 Original-Received: from localhost ([::1]:57006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLtc0-0004je-Ni for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Feb 2022 16:19:20 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLtbi-0004jV-4f for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 16:19:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40103) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLtbh-0006zQ-Qp for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 16:19:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nLtbh-0002k9-OB for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 16:19:01 -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 21:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54074 X-GNU-PR-Package: emacs Original-Received: via spool by 54074-submit@debbugs.gnu.org id=B54074.164539190610503 (code B ref 54074); Sun, 20 Feb 2022 21:19:01 +0000 Original-Received: (at 54074) by debbugs.gnu.org; 20 Feb 2022 21:18:26 +0000 Original-Received: from localhost ([127.0.0.1]:34000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLtb8-0002jL-Ir for submit@debbugs.gnu.org; Sun, 20 Feb 2022 16:18:26 -0500 Original-Received: from sonic307-2.consmr.mail.bf2.yahoo.com ([74.6.134.41]:42520) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLtb6-0002j7-TT for 54074@debbugs.gnu.org; Sun, 20 Feb 2022 16:18:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1645391898; bh=5j2O15tY3+ffk4t/DM56Zw+A90BcoREvSXAwZJa3GVM=; h=Date:From:To:CC:Subject:In-Reply-To:References:From:Subject:Reply-To; b=LBi5oKBew1X+PEajTwqe6TPguR/A0ZkGPiMx1Ku243NIxrxhXE0ZcEVCoI65TTHxePNYr1OS8bWOOCOAVhBbT8sCuk4GzPIRPqARGereRasbS+9JTQElSVLP7eyfhSXkvhjTlDzkXtrMCMh8I0RapkVC7fi6RGX3TV9YkIIOWRChmb4fFVI6ADakHqZaL0yG1GI8nyeeImotUrAUvQthLSGsgBp5Z1UwQGx2jSjrlVqgbVK1PljJ7q8RnmyI/vfVR+awv5Ugoe86K54Egs/J+WWyYfDhHM5toDPtcVMuTfn41NLV27q/qMPtVHCIdg8aq2tDQEp3dbHdcyFm4ScdAQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1645391898; bh=/kp25icIijcELD6y7ZWXymkOc+9nEW/JlEFx+USOQpA=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=jwTBroffJug0mK+OcrzULBSEEaQ42Eouu34ROHzEW67jlaT0FQ27cOQjJcdiqm8p+lm0szSUvlLceNnSWE3NCPGobks7+E6psQUQiky/+9Cx7HBR8HC9W8OUKw2LhtJV+ABy522QXLkxcFd1iqr0SEu7fBR+Kv2IhTHoUM67ERM4dqLeUsiw9Vwa0Qwe6anznewwJxXGmlhN1D+aGsoCiv56x3QqiE4Onb8y9IrtMobQ38zM005m8QV4va9Jhl1pJN+I1cSd7exdY9p0Fx4danzC2K7Oiz8PPV1mC22FeHoeq0WTbfNMb/TWZMg6mJjoYmasdrWNuZKK21zHBNz18g== X-YMail-OSG: mgO9MTAVM1mDS5XSuit0J8u4KVVlJS2Y3BD5CxZ9dvgkvtJTiztlmLbKSzcOfZe XCTn562hR_TlPMHLh1EIRruxhQwdJgnnud_SJYku1nFIWKyqBnoiqzr8izpLIyfzQ_UGlPhh_Zb3 B_J9rk1JGBmT7I2CDaFtMqnjuc4RRS13CG2cNPmtZ.ae8b82K.tBl0IN9oQ7HUdqeZ0LESa_ai9d EY92sMXsOO7tJT8aic74Q3zVr_plQKFjjN7eKfEEYHQzGEJDeS4cWNZalGJxgGBXzm7uZ7MQnopm 3V48oGQuUpuafU_0Zeo5UnAYLV8yym66UnGlqkwTP_dQzYWH6byaLTYBKT6.Ip7smB0ADFh0HEB_ DG7aZFESUxbKo9kz.eawl9FpL7smZScQSmTqtHCtlnCcXWqXjJMK8Io.afh4fXxVDeMFSDxKuX50 tdRttunnW7dNIii52TUuCFolQsJ2YVDwATfXxaaHRs.rIkzAmp7BZV719j37GCAtyvfxpU4gW4FN MYvUnW4r8dHxfeOJlZaoI83IovBJ.1PqCsb4StKmyosGpQRozS_l5rxGppv36kBK.Xntrrdtz13K e6TwlKEm45wOWJyBL992JI8vCd5sMTUZIlQ.o_jLEjHwhzjM0worisePNVqmVe38trwEKFytiuT. U9oDHy21JpoTIm59gRE4Lv2hvSw_TN3uCSI.0D7HWDWLSXp68ZXzUJQjVkeFWP1lOMF3jvkxd4J5 rLrW0Z8KX3bZYlLfJ0kjQ0y53GaFmlZ3guk3.FKbkTO52hsF3lNwYFWPUF7RI6xjzXj5f.8CjJEL 5_VI1AUHqnEsZ6YoB81cb1GfHMH7H3_D4QR1VOGA5j X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.bf2.yahoo.com with HTTP; Sun, 20 Feb 2022 21:18:18 +0000 Original-Received: by kubenode519.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 1d2e19827e80cb2b80d45cf49d3909a2; Sun, 20 Feb 2022 21:18:13 +0000 (UTC) In-Reply-To: <87czjhmior.fsf@gnus.org> X-Mailer: WebService/1.1.19797 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol 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:227279 Archived-At: On February 20, 2022 8:39:16 PM GMT+01:00, Lars Ingebrigtsen wrote: >Ergus writes: > >> 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)=2E The issue comes when they want to disable the mode, beca= use >> 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 se= t >> and then bring it back when unset=2E > >I'm not sure I understand the use case=2E Isn't the way to do this just >to have my-mode add itself to isearch-mode-hook, and then have my-mode >have a minor mode keymap with the prefix it uses? > Actually the mode does not need to be only for isearch-mode=2E=2E=2E It ca= n be a global mode that adds multiple other stuff + some extra search comma= nds=2E=2E=2E It only needs to be enabled once=2E=2E=2E And in general there= is not any reason to force it's keys to add an extra prefix=2E=2E=2E Adding 1 command to isearch-mode-map is fine=2E=2E=2E Suppose we need to a= dd 5=2E=2E=2E Then it is easier to have a map and add it inline to isearch-= mode-map=2E=2E=2E >> Something similar happens to some variables that are modified in minor >> modes and then should be restored=2E=2E=2E this forces sometimes to res= tart >> emacs=2E=2E=2E (for example completion-styles in fido-mode or some hook= s that >> are always added and then need to be removed=2E=2E=2E all these is very >> mechanic and increases code and sources of errors=2E=2E=2E)=2E >> >> The best approach for this one is to save the original value in an alis= t >> and assign with a wrapper around setq=2E=2E=2E and use a loop when dis= abling >> the mode to restore the original values=2E=2E=2E=2E it is not perfect, = but works >> in many cases=2E=2E=2E > >I don't think there's any general mechanism that's possible for this=2E >Any package may mogrify any variable (destructively or not), and only >the package can know what it has to do to bring things back to normal >when the package is switched off=2E > --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E