1

Is there any way to have all text with a specific face also receive a specific text-property?

As a concrete example, there is a special text-property, line-prefix, that I would like to use for some face, however this is a text property, not a face attribute, so adding such a attribute to the face doesn't appear to do anything, e.g.:

(set-face-attribute 'dap-ui-verified-breakpoint-face nil
                     :weight 'bold
                     :slant 'italic
                     :line-prefix "*")
4
  • The answer depends on how the face was originally inserted into the buffer in the first place. Was this done using font-lock? If so, is it a package that you write yourself, or does it come from a third party? Mar 10, 2022 at 14:48
  • Unfortunately, the faces are not controlled by myself but are inserted by a third-party package (dap-mode to be specific)
    – Xaldew
    Mar 10, 2022 at 15:26
  • I don't know the package, but it looks like things like this is done in dap-ui--make-overlay. If you run under a window system, it defined fringe symbols. You could probably modify it for terminal use (which I guess is your reason for using line-prefix). How knows, maybe you can suggest this as a possible enhancement to the package. Mar 10, 2022 at 19:18
  • 1
    Yeah, I'm running this inside a terminal, which doesn't support margins/fringes, and consequently doesn't display any breakpoint indications by default, hence the effort and questions. Although that is an interesting find, maybe I'll spend some time to change that function to allow arbitrary text properties and send them a pull-request
    – Xaldew
    Mar 10, 2022 at 20:16

1 Answer 1

2

You can't add nonexistent face properties to faces. (You can add any properties you like to face symbols, but that's not the same thing.)

But you can add nonexistent (and existent) text properties to all (or to just some) occurrences of buffer text that has a given face.

You can do that easily with library isearch-prop.el. You can do it using command isearchp-add-prop-to-other-prop-zones:

isearchp-add-prop-to-other-prop-zones is an interactive compiled Lisp function in isearch-prop.el.

(isearchp-add-prop-to-other-prop-zones PROP-TO-ADD VALUE-TO-ADD PROP-TO-FIND VALUE-TO-FIND TYPE-TO-FIND &optional START END MSGP)

Add text property to text that has another property, from START to END.

PROP-TO-ADD and VALUE-TO-ADD are the property to add and its value.

PROP-TO-FIND, VALUE-TO-FIND, and TYPE-TO-FIND are the existing property, its value, and its type (symbol text or overlay).

START and END are the buffer limits, or the region limits if active.

Interactively, you are prompted for the required arguments.

Returns non-nil if the property was added, nil if not.

See also Isearch+.

1
  • Suspected as much, and that's a good solution/workaround. Now I just need to find an appropriate hook where this can be called!
    – Xaldew
    Mar 10, 2022 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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