I'm interested in displaying adjacent boxed text using the :box t face property in the following manner for adjacent text:

visibly delimited adjacent boxes

Is there an accepted convention for delimiting/isolating text properties between otherwise uninterrupted text?

For review (from Face Attributes):


Whether or not a box should be drawn around characters, its color, the width of the box lines, and 3D appearance.

Since face and text properties are attached to characters this particular face property is sort of an odd member among text/face properties. Almost all other properties I can think of would not be expected to make a visual distinction that a text property was "interrupted" between adjacent visible characters. Whereas with :box you may wish to have a box boundary between respective "boxes". I can also imagine wanting to "reset" a stipple pattern (thereby potentially interrupting the tiling pattern). If you can think of any other circumstances please comment.

The only approach that came to mind other than using a null character (which doesn't work) was to include an arbitrary string and mark it invisible:

  (propertize "foo"
              'font-lock-ignore t
              'face '(:box t))
  (propertize "X"
              'invisible t)
  (propertize "bar"
              'font-lock-ignore t
              'face '(:box t))))

Incidentally I suspect that I found a rendering bug in emacs while considering this. The following code renders as follows, but transitions to the desired rendering when the cursor moves to adjacent to the invisible character.

enter image description here

  • It's unclear whether or not you should draw one or two boxes. (Ideally, another solution should be implemented, say a :box-start property, so you would not have to resort to hacks like invisible text.) I can reproduce the rendering bug with Emacs 25.1 under Windows. Please report it as a bug to the Emacs team. – Lindydancer Dec 22 '16 at 12:51
  • I have thought before that there should a character which is a "zero-width space"; considered as a space for word breaks etc, but be basically invisible. I'm surprised it does not yet exist. I suppose it should be a Unicode character, but you might also accomplish it with some Emacs magic. – jtgd Dec 25 '16 at 7:22

Your Answer

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

Browse other questions tagged or ask your own question.