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.bugs Subject: bug#23255: Running (prettify-symbols-mode) twice adds two entries to font-lock-keywords Date: Sat, 9 Apr 2016 15:00:54 -0400 Message-ID: <57095166.6080501@live.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eETrDLI0SaCwn576riqk33MamMsj0rcBI" X-Trace: ger.gmane.org 1460228535 22260 80.91.229.3 (9 Apr 2016 19:02:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Apr 2016 19:02:15 +0000 (UTC) To: 23255@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 09 21:02:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1aoy94-0007at-SQ for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Apr 2016 21:02:11 +0200 Original-Received: from localhost ([::1]:32810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoy94-00013I-AL for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Apr 2016 15:02:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoy8z-00010m-S4 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2016 15:02:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoy8w-00039o-Lz for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2016 15:02:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoy8w-00039k-Jf for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2016 15:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1aoy8w-00058c-E4 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2016 15:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Apr 2016 19:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23255 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.146022846919686 (code B ref -1); Sat, 09 Apr 2016 19:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Apr 2016 19:01:09 +0000 Original-Received: from localhost ([127.0.0.1]:56362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoy85-00057S-9I for submit@debbugs.gnu.org; Sat, 09 Apr 2016 15:01:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57256) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoy84-00057D-Ae for submit@debbugs.gnu.org; Sat, 09 Apr 2016 15:01:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoy7y-0002xl-HQ for submit@debbugs.gnu.org; Sat, 09 Apr 2016 15:01:03 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:38229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoy7y-0002xh-EU for submit@debbugs.gnu.org; Sat, 09 Apr 2016 15:01:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoy7x-0007Px-Bt for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2016 15:01:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoy7u-0002ww-50 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2016 15:01:01 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.134]:51807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoy7t-0002wl-R1 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2016 15:00:58 -0400 Original-Received: from [18.189.83.142] ([18.189.83.142]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0MG2eU-1b3qEI3Ak2-00EtbT for ; Sat, 09 Apr 2016 21:00:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 X-Provags-ID: V03:K0:6Ft4zRI5DBC6m+s447EvKs2T+cAWAatfwmiiSIGEZtVcSSELcvR ANBCR7/Vwmg2DnJW+MJ9OBUY7KRKV3upcShd0ZHoanxfwez5sSDcTSJtdfUIWFds5ny2DzC kd/LWBMAizsJTq5KsSh7Fph6WXs6OjXHDB0O47OoKey0xd5SiZRG4JDDntPd7bAyr6Y8z6h DySXgN/94XAqlH8+7cPKg== X-UI-Out-Filterresults: notjunk:1;V01:K0:c89GaafUZII=:KobMUO7HZlq8D021jysLXK 5Ir+wC3U8cvHgHiWUYpW7Ka0dV6PwYh6ZkHOzs1H5OQHd9A4Un8ht0xAGYymsFZahAqu85McJ 0cLYlCmOlxvxTaz8iHMjzuCIltab9GeM32RcuiMWnOliM9T4Ow0bb08eYNmkryhmj/6R9mCXc SIIYuh0wLwzzGrNMIsGMypGjg6h2ODU1sdiq0MEArHntJxt/Plu68nPjbo5pFpt7+wNytGGaU K86l1Za1wM3Y1dsQYLFCC4DSH5bE9fHUUfsHG+j0yJci9J8gO9ytpf6JSKXFE+M9IHzvYBfAE tmXOMpvaMRgWa9yf388C9QOFAMM+q+SgYGKJCPGsYrtoLdbvaxpQwuuOmBP1o5qV4rwLBc1Vg QRBzYJBRVYrwLwW0BdEMBoTpE0TYlZe7H82hmDDg0V6UBfzDGdaNj9WbAlJ6IQs2RnyFBJ56A L3B0/xnwjtQz3QrCwRPL68SXJsSIaTTJkFbT33Hrv0hUuDS60+rXmJFvmuBOe2PdE3m39RcMS XpCcdjHKNyHz6ibKipvosRCDHMFKrDDmCR0IvZFxl0eHOnNc0jAduAs7AgMM/y8fuS2jXixHh spwIhIXhvdEtBVfa76Ag2u/YDATTZjAmPyGmMeDwN8E02MNjmwIkRCim6kqRJ+839KekoWr69 zuJxz6e3eiADmDcA1M0ljKh99hqMerwNLxaWiv1XG2Zfb6Zk167PbjzN2AUHdt8NHWrM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:116286 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eETrDLI0SaCwn576riqk33MamMsj0rcBI Content-Type: multipart/mixed; boundary="aHL3wKUeRfdxaHoFoOQBaPpTj0X7oahvN" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: bug-gnu-emacs@gnu.org Message-ID: <57095166.6080501@live.com> Subject: Running (prettify-symbols-mode) twice adds two entries to font-lock-keywords --aHL3wKUeRfdxaHoFoOQBaPpTj0X7oahvN Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. --aHL3wKUeRfdxaHoFoOQBaPpTj0X7oahvN-- --eETrDLI0SaCwn576riqk33MamMsj0rcBI 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) iQIcBAEBAgAGBQJXCVFmAAoJEPqg+cTm90wjdwkP/A7CQJbdG+P9lA49plOdW57N ZQdt9X7GTr0mgwZhHQWvMZBxRNFgqQ2jnaVkAohYXuE1u54kQNNO0uM9b1kkfrsv 6dypadJOMdnzCuzDMNJ2bOUetTNwcDz3rJRki1iHF0+/x0aQK+po+6xBlZti6qx7 1V7WnGDovd8diIC1MVPI2/LaOkTyVLdc+I/jfNPbp6CjlRYfmmckkFDdB+6u34ns TcF5Ny0J/hKaX01tdpfIspyFmb54nAjyP536uToMkRkq2OFlRn8Rjv1mvM1aAmaT tJF7tq7H4Cuw0u7mPDQ1G9eqhrkaWGfiEe7pQXelTHaM/CnVZOMRW+nBiUnJvaHI WHYC0IUWYwWIHHHbaTJ5WTCF5MS0bCXgCJgc2QoGN5y84zt/FT5zctaeCpAFFIIH e47J5mW9kKd8XX8F65YFdiVjbW5Zs5oB1gRHLHOabtqJc5Q7HzXn2chHKuG9nzEY cHIxdspKH1n3dl0HdTFLuHiAxkdc26gPJNUV/LkmScfX/F9wLc9ez6uzOck9QmSi ZWIxZRMxScQddnWX7sP8XgZRKSxoGFZI/broLRfLCXpmCPuaijCQ1R7JYu1tffmm Teo4QWMp2vR4vBKibhQFnFKaJGltXgeqy6yhgQPLv7eI1R7T7e/3w5acDqIUcBpS TKYeO3cTUFSo+0ROA4VO =umWr -----END PGP SIGNATURE----- --eETrDLI0SaCwn576riqk33MamMsj0rcBI--