Open a scratch buffer, paste the following an evaluate it:

(insert (propertize "hello" 'insert-in-front-hooks
                    (list (lambda (&rest unused) (message "test")))))

Typing characters on either side of the resulting "hello" text won't cause the test message to display. According to the documentation it should, so I assume I'm doing something wrong. What gives? I've also tried 'insert-behind-hook and it doesn't appear to fire either.

Emacs version 24.4.1. Tested with -Q as well.


When I yank your code into *scratch*, switch to fundamental-mode (which turns of the minor mode font-lock-mode), and only then evaluate the expression; then it works.

Actually it shouldn't make a difference whether font-lock-mode is enabled or not for properties that are not a member of font-lock-extra-managed-props. So you might be right that there is a bug, as it does appear to matter in this particular case whether that minor-mode is enabled or not.

| improve this answer | |
  • I was unable to duplicate this experiment in a fundmamental-mode buffer -- i.e., the word "test" does not appear in the *Messages* buffer or the echo-area or the *scratch* buffer. – lawlist Jan 17 '15 at 22:05
  • I was actually able to duplicate this. @lawlist did you try with -Q and emacs 24.4.1? – Joseph Garvin Jan 17 '15 at 22:12
  • @tarsius: Why doesn't font lock only touch the properties it cares about, or just add to the existing list? That seems like terrible behavior. Using overlays complicates my implementation because they don't play nice with undo :/ – Joseph Garvin Jan 17 '15 at 22:14
  • @Joseph Garvin -- thank you for the suggestion. I just downloaded a fresh copy from emacsformacosx.com of GNU Emacs 24.4.1 (x86_64-apple-darwin10.8.0, NS apple-appkit-1038.36) of 2014-10-20 on builder10-6.porkrind.org with no user configuration file and still was unable make the word "test" appear in any buffer. Perhaps it's a bug in the OSX versions of Emacs. – lawlist Jan 17 '15 at 22:28
  • @JosephGarvin Well, it's just opt-out instead of opt-in. With makes sense since you, or some package, can add new entries to font-lock-keywords at any time. It's not really feasible to parse those entries for the properties which are being set using font-lock. – tarsius Jan 18 '15 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.