From: "Clément Pit--Claudel" <clement.pitclaudel@live.com>
To: 22761@debbugs.gnu.org
Subject: bug#22761: Surprising interaction between font-lock, invisible text, and point (self-insert-command and insert behave differently)
Date: Sun, 21 Feb 2016 19:19:17 -0500 [thread overview]
Message-ID: <56CA5405.10304@live.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2441 bytes --]
Hi,
I'm running into problems using font-lock to display certain strings as subscripts. The basic goal is to display ‘a__b’ as ‘ab’ with ‘b’ vertically offset. Using font-lock to make ‘__’ invisible and to add (display (raise -0.15)) to ‘b’ works fine. There is a strange interaction between self-insert-command and font-lock, however, and the problem does not happen if using ‘insert’ instead of ‘self-insert-command’.
The problem happens when editing ‘a_foo_b’ to replace ‘foo’ by ‘bar’ (to get ‘a_bar_b’). Removing ‘foo’ leaves ‘__’ in the buffer, which font-lock recognizes: the whole string gets displayed as ‘ab’. Even then, the point is still between the two underscores (it hasn't moved after font-lock added the invisible property to the underscores). Pressing ‘b’ to start inserting ‘bar’ works fine (I end up with ‘a_b_c’), except for one thing: the point gets moved after the second underscore. Thus, pressing ‘ar’ to complete ‘bar’ ends up inserting ‘a_b_arb’.
On the other hand, using ‘M-: (insert ?b)’ to insert the ‘b’ of ‘bar’ leaves the point in the right place.
To reproduce:
1. Open a buffer in fundamental-mode
2. Evaluate the following setup code:
(progn
(setq font-lock-defaults '(nil))
(font-lock-add-keywords nil `((,(concat "[a-z]+\\(__\\)\\([a-z]+\\)")
(1 '(face nil invisible 'subscript))
(2 '(face nil display (raise -0.25))))))
(add-to-invisibility-spec 'subscript)
(make-local-variable 'font-lock-extra-managed-props)
(add-to-list 'font-lock-extra-managed-props 'display)
(add-to-list 'font-lock-extra-managed-props 'invisible)
(font-lock-mode))
3. Insert the following text: before_between_after
4. Place the point after ‘between’; press <backspace> 7 times, to remove ‘between’ entirely.
5. Type ‘between’ (using the key sequence b e t w e e n)
Expected result: buffer contains before_between_after
Actual result: buffer contains before_b_etweenafter
On the other hand, the following protocol works fine:
1-4. Same as before
5. ‘M-: (insert ?b)’
6. Type ‘etween’ (using the key sequence e t w e e n)
Expected result: buffer contains before_between_after
Actual result: buffer contains before_between_after
Cheers,
Clément.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next reply other threads:[~2016-02-22 0:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-22 0:19 Clément Pit--Claudel [this message]
2016-02-22 15:53 ` bug#22761: Surprising interaction between font-lock, invisible text, and point (self-insert-command and insert behave differently) Eli Zaretskii
2016-02-22 16:03 ` Clément Pit--Claudel
2016-02-22 16:38 ` Eli Zaretskii
2016-02-22 17:36 ` Clément Pit--Claudel
2019-10-30 15:55 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56CA5405.10304@live.com \
--to=clement.pitclaudel@live.com \
--cc=22761@debbugs.gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.