From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72624: 31.0.50; minor-mode-overriding-map-alist doesn't have higher priority than local map, which differs from docs Date: Sat, 17 Aug 2024 13:05:04 +0300 Message-ID: <86o75r31nz.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17692"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72624@debbugs.gnu.org To: mr.meowking@tutamail.com, Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 17 12:05:33 2024 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 1sfGJQ-0004SU-Db for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Aug 2024 12:05:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfGJM-0003bn-US; Sat, 17 Aug 2024 06:05:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sfGJJ-0003Zz-Ek for bug-gnu-emacs@gnu.org; Sat, 17 Aug 2024 06:05:27 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sfGJH-0000W5-NT for bug-gnu-emacs@gnu.org; Sat, 17 Aug 2024 06:05:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=v+k+SScKsDKxDfNY25Epu+h1ujw/kuFq0Q6pJ1Ht0x0=; b=nNVKKU1mzraFYfsduNcv+y55w8DYgelO8hTC6ou1YW77aqbaB70UqfCHpf5AO6vHuAWQoB8QbPE8QcgVGQYo/rt3o5N2ack2t7VavNUoU5v8Dlsc1aDPXY13rqm00DJIwkZZcU8VciBX1rj1u9TK7LPHEYloPI9QlCAwvH5vIXr50UVll08Y2KzSm2qzyIdBH8jzH9QqQn6K4hWbFmAlVz9UgfujxNAL68fU5cvpMkIO3AROgxUmEUI/cYBsdAlUvfGxorIGl1mNQPCdbInAttceVOOzNrUom92uWNOZktQN5OYKx8OUT4PJQajIwpUkJH8Xawqp8og4j10XDVWxXQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sfGJu-0003bZ-DZ for bug-gnu-emacs@gnu.org; Sat, 17 Aug 2024 06:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Aug 2024 10:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72624 X-GNU-PR-Package: emacs Original-Received: via spool by 72624-submit@debbugs.gnu.org id=B72624.172388915413844 (code B ref 72624); Sat, 17 Aug 2024 10:06:02 +0000 Original-Received: (at 72624) by debbugs.gnu.org; 17 Aug 2024 10:05:54 +0000 Original-Received: from localhost ([127.0.0.1]:53562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfGJl-0003bE-Sp for submit@debbugs.gnu.org; Sat, 17 Aug 2024 06:05:54 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:42868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfGJj-0003az-E3 for 72624@debbugs.gnu.org; Sat, 17 Aug 2024 06:05:52 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sfGJ0-0000OG-UN; Sat, 17 Aug 2024 06:05:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=v+k+SScKsDKxDfNY25Epu+h1ujw/kuFq0Q6pJ1Ht0x0=; b=lPd9BAtATh90aQtHiowQ gBfS3RPBVwBEXXt1WhtgzGdLNJ2jNJBtXKWE+GJZvR2Zhcf2CLpweqmhyx9IXfxLvsILGMO+yLHE4 tfyxcDQ1Zv+UriM2vYpVzZacS2lr2cz7eGxcphwhxGycdExTpcQ5nfy1GOYsYobggBbmIobTM148r a/lNHhPP8rSw/jt1YQQx8ivtcARNa4jo7rJL+HkxBJAFDBVrmBCkY62NeYf672fO27+qs7Nf3FEWT 77IrdI5nfZ0/2+UDx6MSuiX0DG8WR40sXYTOcjNRY9fTQh8aQz2mUzEgMMh81RFdPNWaoicqBv/at roZqGW0HjUANKg==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290255 Archived-At: > Date: Wed, 14 Aug 2024 17:45:03 +0200 (CEST) > From: mr.meowking--- via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > NOTE: please view > https://codeberg.org/meow_king/typst-ts-mode/issues/6#issuecomment-2174390 > for rendered markdown view. > > According to docs `(elisp) Active Keymaps` : > > > Emacs contains many keymaps, but at any time only a few keymaps are > “active”.  When Emacs receives user input, it translates the input event > (*note Translation Keymaps::), and looks for a key binding in the active > keymaps. > > > >   Usually, the active keymaps are: (i) the keymap specified by the > ‘keymap’ property, (ii) the keymaps of enabled minor modes, (iii) the > current buffer's local keymap, and (iv) the global keymap, in that > order.  Emacs searches for each input key sequence in all these keymaps. > > > >   Of these usual keymaps, the highest-precedence one is specified by > the ‘keymap’ text or overlay property at point, if any.  (For a mouse > input event, Emacs uses the event position instead of point; *note > Searching Keymaps::.) > > > >   Next in precedence are keymaps specified by enabled minor modes. > These keymaps, if any, are specified by the variables > ‘emulation-mode-map-alists’, ‘minor-mode-overriding-map-alist’, and > ‘minor-mode-map-alist’.  *Note Controlling Active Maps::. > > > >   Next in precedence is the buffer's “local keymap”, containing key > bindings specific to the buffer.  The minibuffer also has a local keymap > (*note Intro to Minibuffers::).  If there is a ‘local-map’ text or > overlay property at point, that specifies the local keymap to use, in > place of the buffer's default local keymap. > > ‘minor-mode-overriding-map-alist` should have higher priority than the buffer local keymap. > However, the actual behavior is different than what the docs say. > > Here is my test: > > ```elisp > ;;;###autoload > (defvar-keymap typst-ts-mode-map > ;; .. > "RET" #'typst-ts-mode-return) > > (defvar-keymap mk/test-map > "RET" #'(lambda () (interactive) (message "mk/test-map"))) > > ;;;###autoload > (define-derived-mode typst-ts-mode text-mode "Typst" > "Major mode for editing Typst, powered by tree-sitter." > :group 'typst > :syntax-table typst-ts-mode-syntax-table > :after-hook > (typst-ts-mode-after-hook-function) > > (setq minor-mode-overriding-map-alist '((outline-minor-mode . nil))) > (setcdr (assq #'outline-minor-mode minor-mode-overriding-map-alist) mk/test-map) > > ;; ... > ) > ``` > In this situation, `typst-ts-mode-return` will be executed.  > > If we execute this elisp code and then re-enter `typst-ts-mode` > ```elisp  > (keymap-set outline-minor-mode-map "" #'(lambda () (interactive) (message "outline-minor-mode-map"))) > ``` > it will still execute `typst-ts-mode-return` function. > > However, in addition of the previous code, if we then remove the following code in `typst-ts-mode` setup process: > ```elisp > (setq minor-mode-overriding-map-alist '((outline-minor-mode . nil))) > (setcdr (assq #'outline-minor-mode minor-mode-overriding-map-alist) mk/test-map) > ``` > then the lambda function in `outline-minor-mode-map` will be executed.  Stefan, any comments or suggestions?