From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Newsgroups: gmane.emacs.devel Subject: Running (prettify-symbols-mode) twice adds two entries to font-lock-keywords Date: Sat, 27 Feb 2016 10:07:07 -0500 Message-ID: <56D1BB9B.7030202@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fvC3h0QRqVIkhGKwQBNvgG3IRT7WhqXcp" X-Trace: ger.gmane.org 1456585651 7384 80.91.229.3 (27 Feb 2016 15:07:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Feb 2016 15:07:31 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 27 16:07:23 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aZgSn-0003Ub-DH for ged-emacs-devel@m.gmane.org; Sat, 27 Feb 2016 16:07:21 +0100 Original-Received: from localhost ([::1]:55136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZgSj-0007vM-HD for ged-emacs-devel@m.gmane.org; Sat, 27 Feb 2016 10:07:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZgSf-0007vG-BH for emacs-devel@gnu.org; Sat, 27 Feb 2016 10:07:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZgSc-0000Ep-0i for emacs-devel@gnu.org; Sat, 27 Feb 2016 10:07:13 -0500 Original-Received: from mout.kundenserver.de ([217.72.192.75]:56362) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZgSb-0000DQ-Ml for emacs-devel@gnu.org; Sat, 27 Feb 2016 10:07:09 -0500 Original-Received: from [18.189.69.235] ([18.189.69.235]) by mrelayeu.kundenserver.de (mreue102) with ESMTPSA (Nemesis) id 0MJTL9-1ac9AN2Avb-0033cZ for ; Sat, 27 Feb 2016 16:07:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 X-Provags-ID: V03:K0:w5VfqvYydvdZA7nIKgENSdyE2AL7KEdyOcNqAaA8dqkHrOZLOjR CxBQoRdnKC154nEE258gwv81Sk0KAb6JdR/3TDdOYNEITvQXLQGYh7ab3i2OUIXqyGFUZ1b 1JHC3stkABdTjr9uDT8nhUZD9u1eE+Zeiplvmrajzh7R43u5uj8reRyA9oTTOhV/6+DzFQy 56vpzU0dJyMjtlyCguYmg== X-UI-Out-Filterresults: notjunk:1;V01:K0:baZW5Q4nSyI=:lOW7xburuzyNiQ5i61Pj4D EjucTE4RPVS+UqvesOhBSxFmMJBlyOrusAELNSOLZ8kwk6oH12eifiHoGATTXPc9MlFCJi2UB 2GyBhCcteFmmREfWMN+HulOT4FgDG9Aa4/W30vaJnHW9nTjVjP53LINe0+AlkzW1NPvb+BJUR 88YF8LehXqlaopG8ioNGxh34ohkuJwI/uc3agFgd8KWOO6k0+l8l9WEpGc9/32jACsJBM4GFj XQ4f7UpC0NGLRXiO/+QaMCr/WnmRxQt7ZDBe/fR18HuFQR6OYoaxTcciTRQKhZn8SFWI97ZTQ LljXJA3UylRV23YkiJMw97/WWefhVOwopARoa5+g0Hdwxfbw2jTymesa6KCsZRmygCgB/7r47 4vtnOL76m0B/hFXu7dq8a/l5QSQdkDBZQVQ6/SgP6r+2HLsDNOs6YaeNfvuf3oQ1VQgNSzhd/ B7rns7f6FPt8T89/bztfGSVMbv1xa6flDjJCbb/sABhr6K3/IjlPU579Z6sGF2fBCgvvROlRq rgiffLnUr7pnxuATB0NkeM8MSQBRUtlpPL7ZJuygMrc/Brdq31vIxeKbPYJEuTnok0AUxE8Dc O1roOm+XTcuxD/XLWCgOf6JDLn7kddPu/ftmGpeEkPQXVuCKi+QDFLyGlcTvJVRAr5k8mUsjg QaIe4IoancJWNT5g6mmEanTk0/sLbMCopsFsob30MX1bHChPxNXxKf+b6T2XT464kLXU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.75 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:200717 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fvC3h0QRqVIkhGKwQBNvgG3IRT7WhqXcp Content-Type: multipart/mixed; boundary="bHV1OvjTBFhljjNUpSEHGUCd3dNTwV5N2" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: Emacs developers Message-ID: <56D1BB9B.7030202@gmail.com> Subject: Running (prettify-symbols-mode) twice adds two entries to font-lock-keywords --bHV1OvjTBFhljjNUpSEHGUCd3dNTwV5N2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi emacs-devel, Do bug reports with a proposed fix go on the bug tracker, or on this list= ? I've seen patches discussed here, so I'm not too sure. Apologies if thi= s is the wrong place (please do let me know!) Changing the lists of symbols prettified by prettify-symbols-mode is more= tricky than it should be; I think this is a bug in prettify-symbols-mode= =2E Here is a test case: (with-current-buffer (get-buffer-create "fl") (erase-buffer) (emacs-lisp-mode) (prettify-symbols-mode -1) (setq prettify-symbols-alist '(("A" . ?B))) (prettify-symbols-mode) (setq prettify-symbols-alist '(("A" . ?C))) (prettify-symbols-mode) (insert "A A A") (pop-to-buffer (current-buffer))) Looking at this code, I expect =E2=80=9CC C C=E2=80=9D to be shown. Yet i= t's not the case; instead, =E2=80=9CB B B=E2=80=9D is shown. On the other hand, this works: (with-current-buffer (get-buffer-create "fl") (erase-buffer) (emacs-lisp-mode) (prettify-symbols-mode -1) (setq prettify-symbols-alist '(("A" . ?B))) (prettify-symbols-mode) (prettify-symbols-mode -1) (setq prettify-symbols-alist '(("A" . ?C))) (prettify-symbols-mode) (insert "A A A") (pop-to-buffer (current-buffer))) I think the line indicated by !!! in the following code sample is wrong: (define-minor-mode prettify-symbols-mode (...) (if prettify-symbols-mode ;; Turn on (when (setq prettify-symbols--keywords (prettify-symbols--make-= keywords)) (font-lock-add-keywords nil prettify-symbols--keywords) ;; !!= ! HERE (setq-local font-lock-extra-managed-props (append font-lock-extra-managed-props '(composition prettify-symbols-start prettify-symbols-end))) (when prettify-symbols-unprettify-at-point (add-hook 'post-command-hook #'prettify-symbols--post-command-hook nil t)) (font-lock-flush)) Indeed, turning on prettify-symbols-mode twice in a row causes two entrie= s to be added to font-lock-add-keywords. This is not an issue in general,= except if one changes prettify-symbols-alist between two calls. In that = case font-lock-keywords gets two distinct entries for prettify-symbols, a= nd the second one is ignored. The proposed fix is to move the following snippet up, so that it runs in = all cases, instead of just running when prettify-symbols-mode is turned o= ff. (when prettify-symbols--keywords (font-lock-remove-keywords nil prettify-symbols--keywords) (setq prettify-symbols--keywords nil)) Cheers, Cl=C3=A9ment. --bHV1OvjTBFhljjNUpSEHGUCd3dNTwV5N2-- --fvC3h0QRqVIkhGKwQBNvgG3IRT7WhqXcp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJW0bubAAoJEPqg+cTm90wj9WYQAIokxxqaZpzBctBfMvhs3RVh i1RPFGTiczHoD+tt2CZL0CupGgTBoc98Ip0pc8AgRKSoYW2Bh0CpdKppqBH5zW3t BIfe2qLUSixg3drL89Xt+5K/mWk3vjlVIzebl4Ty5AsBT3JFnE4khN/XjmZGLgNK 9eIJogaViNshUWdE9NN1ulWbPTk0rPTMZMyarL1U7OuQNDtLp93SujXMMs8IW3cI VaWsVBtzixh080hshEYVY0tPwLJSE6Jq2wuKVCeELHsmksfST7amM5CGqypvFxzl 2vvOpyQauU110OVp17NiPbZWcxkaF9tqI1yU3YuAKQisCmKQP3z+gz+gOJm2bYTk sV36tC6GGYv6Z2sG3xqQhAfo9DeyUIqgtxziXof035t+3dZlSlfCZGPy2v1q8a7Y 76wl2jjS8Cwugjms4EG1BZruc+RngyMRXLzZRCbfYU1IWl56hxehLoqg3rn5gx3T GNsP7u7D9not8u6xq+HbqIQVYAy4r3aAhYL+XkjE8vld6Dlnm8gADeJI2qSfn74O aQ5F4YiKWdrkFQZ4UKGD1HUEeUUZmNMxLCBHHNeHxB9VlztfDxKY1ZfHz6pjpDW9 iR76Ahfqfgo53GMxAbCuImTakRGru73FKGTxLFgf/7nEs6umx8mnsFRFHzysLRxX 7lLYcCeel6OX4Ru5gMd/ =YOSx -----END PGP SIGNATURE----- --fvC3h0QRqVIkhGKwQBNvgG3IRT7WhqXcp--