GNU bug report logs - #37455
27.0.50; insert-behind-hooks and insert-in-front-hooks in text properties do nothing when font-lock-mode is on

Previous Next

Package: emacs;

Reported by: 'Ihor Radchenko' <yantar92 <at> gmail.com>

Date: Thu, 19 Sep 2019 00:53:02 UTC

Severity: normal

Found in version 27.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37455 in the body.
You can then email your comments to 37455 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37455; Package emacs. (Thu, 19 Sep 2019 00:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 'Ihor Radchenko' <yantar92 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 19 Sep 2019 00:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 'Ihor Radchenko' <yantar92 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; insert-behind-hooks and insert-in-front-hooks in text
 properties do nothing when font-lock-mode is on
Date: Thu, 19 Sep 2019 08:48:57 +0800
Expected behaviour:

According to the manual, adding insert-in-front-hooks or
insert-behind-hooks text properties should trigger the functions listed
in the hooks when the text is inserted in front/behind the text.

Observed behaviour:

The functions never run unless I type very fast (with my own config) or
when font-lock-mode is enabled.

Steps to reproduce (the font-lock part):
1. emacs -Q
2. Insert the following elisp into scratch (the code is from https://www.reddit.com/r/emacs/comments/d5waor/how_to_use_modification_hooks_in_text_properties/):

(defun test-property ()
  (put-text-property (point) (mark) 'insert-behind-hooks
		  (list (lambda (beg end)
			     (message "before %d %d" beg end))))
  (put-text-property (point) (mark) 'insert-in-front-hooks
		  (list (lambda (beg end)
			     (message "in front %d %d" beg end)))))

1. Select the region containing all the text in the scratch buffer
2. M-: (test-property) RET
3. Try to type anything
4. No message is shown
5. Disable font-lock-mode
6. Try to type anything
7. The message is shown

Regards,
Ihor

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: yantar92 <at> gmail.com, ihor_radchenko <at> alumni.sutd.edu.sg





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37455; Package emacs. (Thu, 19 Sep 2019 14:12:01 GMT) Full text and rfc822 format available.

Message #8 received at 37455 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: 'Ihor Radchenko' <yantar92 <at> gmail.com>
Cc: 37455 <at> debbugs.gnu.org
Subject: Re: bug#37455: 27.0.50;
 insert-behind-hooks and insert-in-front-hooks in text properties do
 nothing when font-lock-mode is on
Date: Thu, 19 Sep 2019 17:11:53 +0300
> From: 'Ihor Radchenko' <yantar92 <at> gmail.com>
> Date: Thu, 19 Sep 2019 08:48:57 +0800
> 
> Expected behaviour:
> 
> According to the manual, adding insert-in-front-hooks or
> insert-behind-hooks text properties should trigger the functions listed
> in the hooks when the text is inserted in front/behind the text.
> 
> Observed behaviour:
> 
> The functions never run unless I type very fast (with my own config) or
> when font-lock-mode is enabled.

We have too many hooks, and they fight each other.  Recursively.

Should be fixed now on the master branch.  Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37455; Package emacs. (Thu, 19 Sep 2019 16:51:02 GMT) Full text and rfc822 format available.

Message #11 received at 37455 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 37455 <at> debbugs.gnu.org
Subject: Re: bug#37455: 27.0.50; insert-behind-hooks and
 insert-in-front-hooks in text properties do nothing when font-lock-mode is
 on
Date: Fri, 20 Sep 2019 00:46:52 +0800
Thanks!
I can confirm that the hooks work as expected in master.

Also, a word about the property names (from reddit comment by @00-11
https://www.reddit.com/r/emacs/comments/d5waor/how_to_use_modification_hooks_in_text_properties/f0q54zn/):

"Too bad they have names that end in -hooks, which is misleading. Even
if they were actually hooks (which are variables), because their
functions take arguments they would be considered "abnormal
hooks", and abnormal hooks are conventionally named with the
suffix -functions (not -hooks). Following that convention would
also be less misleading, lessening the suggestion that they're
hooks."

Would it make sense to change the text and overlay property names to
something like insert-in-front-functions, insert-behind-functions, and
modification-functions?

Regards,
Ihor
      

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: 'Ihor Radchenko' <yantar92 <at> gmail.com>
>> Date: Thu, 19 Sep 2019 08:48:57 +0800
>> 
>> Expected behaviour:
>> 
>> According to the manual, adding insert-in-front-hooks or
>> insert-behind-hooks text properties should trigger the functions listed
>> in the hooks when the text is inserted in front/behind the text.
>> 
>> Observed behaviour:
>> 
>> The functions never run unless I type very fast (with my own config) or
>> when font-lock-mode is enabled.
>
> We have too many hooks, and they fight each other.  Recursively.
>
> Should be fixed now on the master branch.  Thanks.

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: yantar92 <at> gmail.com, ihor_radchenko <at> alumni.sutd.edu.sg




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 19 Sep 2019 17:36:01 GMT) Full text and rfc822 format available.

Notification sent to 'Ihor Radchenko' <yantar92 <at> gmail.com>:
bug acknowledged by developer. (Thu, 19 Sep 2019 17:36:02 GMT) Full text and rfc822 format available.

Message #16 received at 37455-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 37455-done <at> debbugs.gnu.org
Subject: Re: bug#37455: 27.0.50; insert-behind-hooks and
 insert-in-front-hooks in text properties do nothing when font-lock-mode is
 on
Date: Thu, 19 Sep 2019 20:35:13 +0300
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Cc: 37455 <at> debbugs.gnu.org
> Date: Fri, 20 Sep 2019 00:46:52 +0800
> 
> Thanks!
> I can confirm that the hooks work as expected in master.

Thanks, I'm therefore closing this bug report.

> "Too bad they have names that end in -hooks, which is misleading. Even
> if they were actually hooks (which are variables), because their
> functions take arguments they would be considered "abnormal
> hooks", and abnormal hooks are conventionally named with the
> suffix -functions (not -hooks). Following that convention would
> also be less misleading, lessening the suggestion that they're
> hooks."
> 
> Would it make sense to change the text and overlay property names to
> something like insert-in-front-functions, insert-behind-functions, and
> modification-functions?

I don't see a serious enough reason to change names of these
properties, which were introduced in Emacs 19(!).  The person who
wrote that raises many similar arguments, so I'm not surprised to hear
this one.

IOW, this ship has sailed decades ago, and it's too late to rename it
now.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 18 Oct 2019 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 190 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.