GNU bug report logs -
#23255
Running (prettify-symbols-mode) twice adds two entries to font-lock-keywords
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23255 in the body.
You can then email your comments to 23255 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23255
; Package
emacs
.
(Sat, 09 Apr 2016 19:02:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Clément Pit--Claudel <clement.pitclaudel <at> live.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 09 Apr 2016 19:02:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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. 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 “C C C” to be shown. Yet it's not the case; instead, “B B B” 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 entries 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, and 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 off.
(when prettify-symbols--keywords
(font-lock-remove-keywords nil prettify-symbols--keywords)
(setq prettify-symbols--keywords nil))
Cheers,
Clément.
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23255
; Package
emacs
.
(Sun, 28 Jul 2019 20:16:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 23255 <at> debbugs.gnu.org (full text, mbox):
Clément Pit--Claudel <clement.pitclaudel <at> live.com> writes:
> 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 off.
>
> (when prettify-symbols--keywords
> (font-lock-remove-keywords nil prettify-symbols--keywords)
> (setq prettify-symbols--keywords nil))
Makes sense. I've now done this on the trunk.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) fixed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sun, 28 Jul 2019 20:16:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 27.1, send any further explanations to
23255 <at> debbugs.gnu.org and Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sun, 28 Jul 2019 20:16:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 26 Aug 2019 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 356 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.