diff options
| author | Eli Zaretskii | 2023-06-18 09:13:02 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-06-18 09:13:02 +0300 |
| commit | eacd75df4e475c3d2483c64f32e3edb3be5c7785 (patch) | |
| tree | a8ed30b8170885ec428e403c51c837b70aa3d354 | |
| parent | b3f11e94fad97144c4bd01c0d6e729d27bc7bfc7 (diff) | |
| download | emacs-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.texi | 55 |
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)} |
| 1795 | This property's value determines the priority of the overlay. | 1795 | This property's value determines the priority of the overlay. If you |
| 1796 | If you want to specify a priority value, use either @code{nil} | 1796 | want 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. | 1797 | a positive integer, or a cons of two values. Any other value triggers |
| 1798 | undefined behavior. | ||
| 1798 | 1799 | ||
| 1799 | The priority matters when two or more overlays cover the same | 1800 | The priority matters when two or more overlays cover the same |
| 1800 | character and both specify the same property with different values; | 1801 | character and both specify the same property with different values; |
| 1801 | the one whose @code{priority} value is larger overrides the other. | 1802 | the 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 |
| 1803 | does not completely override the other value; instead, its face | 1804 | does not completely override the other value; instead, its individual |
| 1804 | attributes override the face attributes of the @code{face} property | 1805 | face attributes override the corresponding face attributes of the |
| 1805 | whose priority is lower.) If two overlays have the same priority | 1806 | @code{face} property whose priority is lower.) If two overlays have |
| 1806 | value, and one is nested in the other, then the inner one will prevail | 1807 | the same priority value, and one is ``nested'' in the other (i.e., |
| 1807 | over the outer one. If neither is nested in the other then you should | 1808 | covers fewer buffer or string positions), then the inner one will |
| 1808 | not make assumptions about which overlay will prevail. | 1809 | prevail over the outer one. If neither is nested in the other then |
| 1810 | you should not make assumptions about which overlay will prevail. | ||
| 1811 | |||
| 1812 | When a Lisp program puts overlays with defined priorities on text that | ||
| 1813 | might have overlays without priorities, this could cause undesirable | ||
| 1814 | results, because any overlay with a positive priority value will | ||
| 1815 | override all the overlays without a priority. Since most Emacs | ||
| 1816 | features that use overlays don't specify priorities for their | ||
| 1817 | overlays, integer priorities should be used with care. Instead of | ||
| 1818 | using integer priorities and risk overriding other overlays, you can | ||
| 1819 | use priority values of the form @w{@code{(@var{primary} . @var{secondary})}}, | ||
| 1820 | where the @var{primary} value is used as described above, and | ||
| 1821 | @var{secondary} is the fallback value used when @var{primary} and the | ||
| 1822 | nesting considerations fail to resolve the precedence between | ||
| 1823 | overlays. In particular, priority value @w{@code{(nil . @var{n})}}, | ||
| 1824 | with @var{n} a positive integer, allows to have the overlays ordered | ||
| 1825 | by priority when necessary without completely overriding other | ||
| 1826 | overlays. | ||
| 1809 | 1827 | ||
| 1810 | Currently, all overlays take priority over text properties. | 1828 | Currently, all overlays take priority over text properties. |
| 1811 | 1829 | ||
| 1812 | Note that Emacs sometimes uses non-numeric priority values for some of | 1830 | If you need to put overlays in priority order, use the @var{sorted} |
| 1813 | its internal overlays, so do not try to do arithmetic on the priority | 1831 | argument of @code{overlays-at}. @xref{Finding Overlays}. |
| 1814 | of an overlay (unless it is one that you created). In particular, the | ||
| 1815 | overlay used for showing the region uses a priority value of the form | ||
| 1816 | @w{@code{(@var{primary} . @var{secondary})}}, where the @var{primary} | ||
| 1817 | value is used as described above, and @var{secondary} is the fallback | ||
| 1818 | value used when @var{primary} and the nesting considerations fail to | ||
| 1819 | resolve the precedence between overlays. However, you are advised not | ||
| 1820 | to design Lisp programs based on this implementation detail; if you | ||
| 1821 | need to put overlays in priority order, use the @var{sorted} argument | ||
| 1822 | of @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 | |||
| 3329 | specified by the @code{mouse-face} property instead. @xref{Overlay | 3338 | specified by the @code{mouse-face} property instead. @xref{Overlay |
| 3330 | Properties}. | 3339 | Properties}. |
| 3331 | 3340 | ||
| 3332 | When multiple overlays cover one character, an overlay with higher | 3341 | When multiple overlays cover the same character, an overlay with |
| 3333 | priority overrides those with lower priority. @xref{Overlays}. | 3342 | higher priority overrides those with lower priority. @xref{Overlays}. |
| 3334 | 3343 | ||
| 3335 | @item | 3344 | @item |
| 3336 | If the text contains a @code{face} or @code{mouse-face} property, | 3345 | If the text contains a @code{face} or @code{mouse-face} property, |