Subject: bug#34764: prettify-symbols-mode pollutes font-lock-extra-keywords

From: Clément Pit-Claudel <[email-masked]>
Date: Tue, 5 Mar 2019 17:15:03 -0500

Hi all,

When turned off, prettify-symbols-mode removes 'composition' from font-lock-extra-keywords, but not prettify-symbols-start or prettify-symbols-end; as a result, every time prettify-symbols-mode is turned on, it adds two new elements to font-lock-extra-keywords.

(I ran into this issue because I added a watcher on font-lock-extra-keywords to debug an intermittent font-lock problem, and the increasingly long lists of prettify-symbol-* entries made things harder to read).

I'm happy to provide a patch, but I'm a bit puzzled by the implementation:

    (remove-hook 'post-command-hook #'prettify-symbols--post-command-hook t)
    (when prettify-symbols--keywords
      (font-lock-remove-keywords nil prettify-symbols--keywords)
      (setq prettify-symbols--keywords nil))
    (when (memq 'composition font-lock-extra-managed-props)
      (setq font-lock-extra-managed-props (delq 'composition
                                                font-lock-extra-managed-props))
      (with-silent-modifications
        (remove-text-properties (point-min) (point-max) '(composition nil))))))

Would it be simpler to just call font-lock-unfontify-region-function and remove all three properties from font-lock-extra-managed-props?

Cheers,
Clément.

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-02-28 built on clem-w50-mint
Repository revision: 5d60229bf1a9a496102fc2a3ef9e57dcce7bef10
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Linux Mint 19.1