aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2023-06-18 09:13:02 +0300
committerEli Zaretskii2023-06-18 09:13:02 +0300
commiteacd75df4e475c3d2483c64f32e3edb3be5c7785 (patch)
treea8ed30b8170885ec428e403c51c837b70aa3d354
parentb3f11e94fad97144c4bd01c0d6e729d27bc7bfc7 (diff)
downloademacs-eacd75df4e475c3d2483c64f32e3edb3be5c7785.tar.gz
emacs-eacd75df4e475c3d2483c64f32e3edb3be5c7785.zip
; Improve documentation of overlay priorities
* doc/lispref/display.texi (Overlay Properties): Don't advise against using overlay property values that are cons cells. (Bug#64101)
-rw-r--r--doc/lispref/display.texi55
1 files changed, 32 insertions, 23 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 9b6e4f609bf..e229935170f 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1792,34 +1792,43 @@ of them:
1792@table @code 1792@table @code
1793@item priority 1793@item priority
1794@kindex priority @r{(overlay property)} 1794@kindex priority @r{(overlay property)}
1795This property's value determines the priority of the overlay. 1795This property's value determines the priority of the overlay. If you
1796If you want to specify a priority value, use either @code{nil} 1796want to specify a priority value, use either @code{nil} (or zero), or
1797(or zero), or a positive integer. Any other value has undefined behavior. 1797a positive integer, or a cons of two values. Any other value triggers
1798undefined behavior.
1798 1799
1799The priority matters when two or more overlays cover the same 1800The priority matters when two or more overlays cover the same
1800character and both specify the same property with different values; 1801character and both specify the same property with different values;
1801the one whose @code{priority} value is larger overrides the other. 1802the one whose @code{priority} value is higher overrides the other.
1802(For the @code{face} property, the higher priority overlay's value 1803(For the @code{face} property, the higher priority overlay's value
1803does not completely override the other value; instead, its face 1804does not completely override the other value; instead, its individual
1804attributes override the face attributes of the @code{face} property 1805face attributes override the corresponding face attributes of the
1805whose priority is lower.) If two overlays have the same priority 1806@code{face} property whose priority is lower.) If two overlays have
1806value, and one is nested in the other, then the inner one will prevail 1807the same priority value, and one is ``nested'' in the other (i.e.,
1807over the outer one. If neither is nested in the other then you should 1808covers fewer buffer or string positions), then the inner one will
1808not make assumptions about which overlay will prevail. 1809prevail over the outer one. If neither is nested in the other then
1810you should not make assumptions about which overlay will prevail.
1811
1812When a Lisp program puts overlays with defined priorities on text that
1813might have overlays without priorities, this could cause undesirable
1814results, because any overlay with a positive priority value will
1815override all the overlays without a priority. Since most Emacs
1816features that use overlays don't specify priorities for their
1817overlays, integer priorities should be used with care. Instead of
1818using integer priorities and risk overriding other overlays, you can
1819use priority values of the form @w{@code{(@var{primary} . @var{secondary})}},
1820where the @var{primary} value is used as described above, and
1821@var{secondary} is the fallback value used when @var{primary} and the
1822nesting considerations fail to resolve the precedence between
1823overlays. In particular, priority value @w{@code{(nil . @var{n})}},
1824with @var{n} a positive integer, allows to have the overlays ordered
1825by priority when necessary without completely overriding other
1826overlays.
1809 1827
1810Currently, all overlays take priority over text properties. 1828Currently, all overlays take priority over text properties.
1811 1829
1812Note that Emacs sometimes uses non-numeric priority values for some of 1830If you need to put overlays in priority order, use the @var{sorted}
1813its internal overlays, so do not try to do arithmetic on the priority 1831argument of @code{overlays-at}. @xref{Finding Overlays}.
1814of an overlay (unless it is one that you created). In particular, the
1815overlay used for showing the region uses a priority value of the form
1816@w{@code{(@var{primary} . @var{secondary})}}, where the @var{primary}
1817value is used as described above, and @var{secondary} is the fallback
1818value used when @var{primary} and the nesting considerations fail to
1819resolve the precedence between overlays. However, you are advised not
1820to design Lisp programs based on this implementation detail; if you
1821need to put overlays in priority order, use the @var{sorted} argument
1822of @code{overlays-at}. @xref{Finding Overlays}.
1823 1832
1824@item window 1833@item window
1825@kindex window @r{(overlay property)} 1834@kindex window @r{(overlay property)}
@@ -3329,8 +3338,8 @@ enough to the overlay, Emacs applies the face or face attributes
3329specified by the @code{mouse-face} property instead. @xref{Overlay 3338specified by the @code{mouse-face} property instead. @xref{Overlay
3330Properties}. 3339Properties}.
3331 3340
3332When multiple overlays cover one character, an overlay with higher 3341When multiple overlays cover the same character, an overlay with
3333priority overrides those with lower priority. @xref{Overlays}. 3342higher priority overrides those with lower priority. @xref{Overlays}.
3334 3343
3335@item 3344@item
3336If the text contains a @code{face} or @code{mouse-face} property, 3345If the text contains a @code{face} or @code{mouse-face} property,