]> git.eshelyaron.com Git - emacs.git/commitdiff
Document :box attribute caveats when used on display strings
authorEli Zaretskii <eliz@gnu.org>
Sat, 18 May 2024 09:15:21 +0000 (12:15 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 18 May 2024 18:53:20 +0000 (20:53 +0200)
* doc/lispref/display.texi (Replacing Specs, Face Attributes):
Mention special considerations when a display string has a
':box' face attribute identical to the surrounding buffer text.
Suggested by JD Smith <jdtsmith@gmail.com>.  (Bug#70637)

(cherry picked from commit df1a9e42ba483f2a0e3747abc7edb16818993f13)

doc/lispref/display.texi

index 59e1f5cd2f288a2e99e125e4a3b4bb5aa0ab00a0..39a5bbc106eff7db2d4c98dcbfeccce1ce7d4add 100644 (file)
@@ -2752,6 +2752,11 @@ being pressed.  If it is @code{pressed-button}, the box looks like a
 @code{flat-button} or omitted, a plain 2D box is used.
 @end table
 
+If you use the @code{:box} face attribute on strings displayed instead
+of buffer text via the @code{display} text property, special
+considerations might apply if the surrounding buffer text also has the
+@code{:box} face attribute.  @xref{Replacing Specs}.
+
 @item :inverse-video
 Whether or not characters should be displayed in inverse video.  The
 value should be @code{t} (yes) or @code{nil} (no).
@@ -5308,6 +5313,34 @@ characters get a second string (@code{concat} creates a new string
 object), so they are replaced with one @samp{A}; and so on.  Thus, the
 ten characters appear as five A's.
 
+@cindex box face attribute, and @code{display} properties
+Note: Using @code{:box} face attribute (@pxref{Face Attributes}) on a
+replacing @code{display} string that is adjacent to normal text with
+the same @code{:box} style can lead to display artifacts when moving
+the cursor across the text with this face attribute.  These can be
+avoided by applying the @code{:box} attribute directly to the text
+being replaced, rather than (or in addition to) the @code{display}
+string itself.  Here's an example:
+
+@smallexample
+@group
+;; Causes display artifacts when moving the cursor across text
+(progn
+  (put-text-property 1 2 'display (propertize "  [" 'face '(:box t)))
+  (put-text-property 2 3 'face '(:box t))
+  (put-text-property 3 4 'display (propertize "]  " 'face '(:box t))))
+@end group
+
+@group
+;; No display artifacts due to `:box'
+(progn
+  (add-text-properties 1 2 '(face (:box t) display "  ["))
+  (put-text-property 2 3 'face '(:box t))
+  (add-text-properties 3 4 '(face (:box t) display "]  ")))
+@end group
+@end smallexample
+
+
 @node Specified Space
 @subsection Specified Spaces
 @cindex spaces, specified height or width