From the Elisp manual:

If an overlay has a category property, we call it the category of the overlay. It should be a symbol. The properties of the symbol serve as defaults for the properties of the overlay.

How can I set the properties of the overlay category?


Use put to set a property of a symbol. Use get to retrieve one property and symbol-plist to retrieve them all. The properties of a symbol are an attribute of it, parallel to its value as a variable (symbol-value) and its function definition (symbol-function).

For example, the following snippet causes overlay to be shown in the default face, but in bold italic when the mouse cursor is over it, because the mouse-face property of the category applies but the face property of the category is overridden by the same property on the overlay itself.

(put 'my-category 'face 'bold)
(put 'my-category 'mouse-face 'bold-italic)
(let ((overlay (make-overlay (point) (1+ (point)))))
  (overlay-put overlay 'category 'my-category)
  (overlay-put overlay 'face 'default)
  • Setting and getting overlay properties is unrelated to setting and getting properties on a symbol's plist. A property with the same name can exist on a symbol's plist, on a character in a buffer or string as a text property, and on overlay positions, but those three properties and their values are totally separate. If you agree, please consider editing the answer to avoid confusion of symbol properties with overlay properties. Maybe just remove the first paragraph? Thx for considering. – Drew Oct 31 '20 at 17:21
  • @Drew I don't understand your comment. The whole point of the category overlay property is that it causes the value of symbol properties to become properties of an overlay. – Gilles 'SO- stop being evil' Nov 1 '20 at 11:50
  • Sorry, yes, that's correct. I don't think you make the connection between the first and second paragraphs. IOW, I don't think you made clear what you (correctly) say in your comment. In the answer, so far, there seems to be no connection between the two paragraphs: one talks about symbol properties; the other about overlay properties. The connection is the behavior of overlay property category and its use of a symbol and its properties. You might consider putting some such info into the answer itself. Just a suggestion. (+1 for the answer, though.) – Drew Nov 1 '20 at 18:21

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.