From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#54074: 29.0.50; Feature request emacs keymap-set and minor-modes Date: Sun, 20 Feb 2022 20:39:16 +0100 Message-ID: <87czjhmior.fsf@gnus.org> References: <87ley5iclc.fsf.ref@aol.com> <87ley5iclc.fsf@aol.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34964"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54074@debbugs.gnu.org To: Ergus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 20 20:40:48 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 1nLs4d-0008u9-Ft for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Feb 2022 20:40:47 +0100 Original-Received: from localhost ([::1]:41714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLs4c-0004bn-HF for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Feb 2022 14:40:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLs3u-0004ab-9U for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:40:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLs3t-0008IW-VL for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:40:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nLs3t-0008Df-Tj for bug-gnu-emacs@gnu.org; Sun, 20 Feb 2022 14:40:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Feb 2022 19:40: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.164538596931533 (code B ref 54074); Sun, 20 Feb 2022 19:40:01 +0000 Original-Received: (at 54074) by debbugs.gnu.org; 20 Feb 2022 19:39:29 +0000 Original-Received: from localhost ([127.0.0.1]:33875 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLs3N-0008CV-Jp for submit@debbugs.gnu.org; Sun, 20 Feb 2022 14:39:29 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:58920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLs3K-0008CC-9D for 54074@debbugs.gnu.org; Sun, 20 Feb 2022 14:39:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=JrhY11wkuEnqLEnTknlw/M6eVtzzQY6isyiwnbYv1x4=; b=R214Jz6VsYUSHltmrdhzbOSyXY kaO/3YcLXUeZ5mq0VARCOBoWeVCQmA1GYXslpBgtSD4+qoTOx2TYxGdcwqtvxietfIaBMkrngAM/K 7qt/2N76J13sfZm0ZvP3DK3Lk6aSBTx75KFSEAuDeQMRhAeBhLADFXj+toWs4boAkfFA=; Original-Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLs3B-0005co-5v; Sun, 20 Feb 2022 20:39:20 +0100 X-Now-Playing: DJ Screw's _All Work, No Play_: "DJ Screw B-Legit Lil Keke Phaz Duke Screw Mix feat B-Legit Lil Keke Phaz Duke " In-Reply-To: <87ley5iclc.fsf@aol.com> (Ergus's message of "Sun, 20 Feb 2022 20:04:31 +0100") 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:227271 Archived-At: 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). 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. I'm not sure I understand the use case. 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? > 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... I don't think there's any general mechanism that's possible for this. 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. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no