unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 51974@debbugs.gnu.org
Subject: bug#51974: 29.0.50; [PATCH] Fix deactivation of outline-minor-mode-cycle-map bindings
Date: Sat, 20 Nov 2021 11:45:40 +0100	[thread overview]
Message-ID: <87ilwnds17.fsf@miha-pc> (raw)
In-Reply-To: <87h7c7qhxv.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> miha@kamnitnik.top writes:
>
>> -                                       'keymap outline-minor-mode-cycle-map)
>> +                                       'outline-cycle-keymap
>> +                                       outline-minor-mode-cycle-map)
>
> I'm not very enthusiastic about messing with char-property-alias-alist
> for something like this, but perhaps this is the best solution here?  I
> guess we don't have a mechanism to make a text property keymap "go away"
> when a minor mode is deactivated?

We have, it's called 'font-lock-extra-managed-props'. Using it, we can
do this in a simpler way:

diff --git a/lisp/outline.el b/lisp/outline.el
index a4d2a3b7d7..7f78c04866 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -427,6 +427,9 @@ outline-minor-mode
         (when (or outline-minor-mode-cycle outline-minor-mode-highlight)
           (if (and global-font-lock-mode (font-lock-specified-p major-mode))
               (progn
+                (when outline-minor-mode-cycle
+                  (add-to-list 'font-lock-extra-managed-props 'keymap
+                               nil #'eq))
                 (font-lock-add-keywords nil outline-font-lock-keywords t)
                 (font-lock-flush))
             (outline-minor-mode-highlight-buffer)))

This has a small disadvantage: deactivating outline-minor-mode will
remove all 'keymap' text properties from the whole buffer, even if they
are added by other minor or major modes or whatever. With
'char-property-alias-alist', we can create a sort of namespacing to
ensure that outline-minor-mode messes only with its own text properties.

'font-lock-mode' minor mode modifies 'char-property-alias-alist' in a
similar way for a similar reason.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

  reply	other threads:[~2021-11-20 10:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 11:41 bug#51974: 29.0.50; [PATCH] Fix deactivation of outline-minor-mode-cycle-map bindings miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-20  9:45 ` Lars Ingebrigtsen
2021-11-20 10:45   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-11-21  8:12     ` Lars Ingebrigtsen
2021-11-21 17:55       ` Juri Linkov
2021-11-21 17:58         ` Juri Linkov
2022-01-11 19:24           ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilwnds17.fsf@miha-pc \
    --to=bug-gnu-emacs@gnu.org \
    --cc=51974@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=miha@kamnitnik.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).