aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 129fee7c095..ee7dce84a5b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1949,7 +1949,7 @@ sort_overlays (overlay_vec, noverlays, w)
1949 1949
1950struct sortstr 1950struct sortstr
1951{ 1951{
1952 Lisp_Object string; 1952 Lisp_Object string, string2;
1953 int size; 1953 int size;
1954 int priority; 1954 int priority;
1955}; 1955};
@@ -1987,10 +1987,9 @@ cmp_for_strings (as1, as2)
1987} 1987}
1988 1988
1989static void 1989static void
1990record_overlay_string (ssl, str, pri, size) 1990record_overlay_string (ssl, str, str2, pri, size)
1991 struct sortstrlist *ssl; 1991 struct sortstrlist *ssl;
1992 Lisp_Object str; 1992 Lisp_Object str, str2, pri;
1993 Lisp_Object pri;
1994 int size; 1993 int size;
1995{ 1994{
1996 if (ssl->used == ssl->size) 1995 if (ssl->used == ssl->size)
@@ -2003,19 +2002,26 @@ record_overlay_string (ssl, str, pri, size)
2003 xrealloc (ssl->buf, ssl->size * sizeof (struct sortstr))); 2002 xrealloc (ssl->buf, ssl->size * sizeof (struct sortstr)));
2004 } 2003 }
2005 ssl->buf[ssl->used].string = str; 2004 ssl->buf[ssl->used].string = str;
2005 ssl->buf[ssl->used].string2 = str2;
2006 ssl->buf[ssl->used].size = size; 2006 ssl->buf[ssl->used].size = size;
2007 ssl->buf[ssl->used].priority = (INTEGERP (pri) ? XINT (pri) : 0); 2007 ssl->buf[ssl->used].priority = (INTEGERP (pri) ? XINT (pri) : 0);
2008 ssl->used++; 2008 ssl->used++;
2009 ssl->bytes += XSTRING (str)->size; 2009 ssl->bytes += XSTRING (str)->size;
2010 if (STRINGP (str2))
2011 ssl->bytes += XSTRING (str2)->size;
2010} 2012}
2011 2013
2012/* Return the concatenation of the strings associated with overlays that 2014/* Return the concatenation of the strings associated with overlays that
2013 begin or end at POS, ignoring overlays that are specific to a window 2015 begin or end at POS, ignoring overlays that are specific to a window
2014 other than W. The strings are concatenated in the appropriate order: 2016 other than W. The strings are concatenated in the appropriate order:
2015 shorter overlays nest inside longer ones, and higher priority inside 2017 shorter overlays nest inside longer ones, and higher priority inside
2016 lower. Returns the string length, and stores the contents indirectly 2018 lower. Normally all of the after-strings come first, but zero-sized
2017 through PSTR, if that variable is non-null. The string may be 2019 overlays have their after-strings ride along with the before-strings
2018 overwritten by subsequent calls. */ 2020 because it would look strange to print them inside-out.
2021
2022 Returns the string length, and stores the contents indirectly through
2023 PSTR, if that variable is non-null. The string may be overwritten by
2024 subsequent calls. */
2019int 2025int
2020overlay_strings (pos, w, pstr) 2026overlay_strings (pos, w, pstr)
2021 int pos; 2027 int pos;
@@ -2042,14 +2048,17 @@ overlay_strings (pos, w, pstr)
2042 window = Foverlay_get (overlay, Qwindow); 2048 window = Foverlay_get (overlay, Qwindow);
2043 if (WINDOWP (window) && XWINDOW (window) != w) 2049 if (WINDOWP (window) && XWINDOW (window) != w)
2044 continue; 2050 continue;
2045 if (endpos == pos
2046 && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
2047 record_overlay_string (&overlay_tails, str,
2048 Foverlay_get (overlay, Qpriority),
2049 endpos - startpos);
2050 if (startpos == pos 2051 if (startpos == pos
2051 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) 2052 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str)))
2052 record_overlay_string (&overlay_heads, str, 2053 record_overlay_string (&overlay_heads, str,
2054 (startpos == endpos
2055 ? Foverlay_get (overlay, Qafter_string)
2056 : Qnil),
2057 Foverlay_get (overlay, Qpriority),
2058 endpos - startpos);
2059 else if (endpos == pos
2060 && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
2061 record_overlay_string (&overlay_tails, str, Qnil,
2053 Foverlay_get (overlay, Qpriority), 2062 Foverlay_get (overlay, Qpriority),
2054 endpos - startpos); 2063 endpos - startpos);
2055 } 2064 }
@@ -2068,14 +2077,17 @@ overlay_strings (pos, w, pstr)
2068 window = Foverlay_get (overlay, Qwindow); 2077 window = Foverlay_get (overlay, Qwindow);
2069 if (WINDOWP (window) && XWINDOW (window) != w) 2078 if (WINDOWP (window) && XWINDOW (window) != w)
2070 continue; 2079 continue;
2071 if (endpos == pos
2072 && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
2073 record_overlay_string (&overlay_tails, str,
2074 Foverlay_get (overlay, Qpriority),
2075 endpos - startpos);
2076 if (startpos == pos 2080 if (startpos == pos
2077 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) 2081 && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str)))
2078 record_overlay_string (&overlay_heads, str, 2082 record_overlay_string (&overlay_heads, str,
2083 (startpos == endpos
2084 ? Foverlay_get (overlay, Qafter_string)
2085 : Qnil),
2086 Foverlay_get (overlay, Qpriority),
2087 endpos - startpos);
2088 else if (endpos == pos
2089 && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
2090 record_overlay_string (&overlay_tails, str, Qnil,
2079 Foverlay_get (overlay, Qpriority), 2091 Foverlay_get (overlay, Qpriority),
2080 endpos - startpos); 2092 endpos - startpos);
2081 } 2093 }
@@ -2107,7 +2119,15 @@ overlay_strings (pos, w, pstr)
2107 tem = overlay_heads.buf[i].string; 2119 tem = overlay_heads.buf[i].string;
2108 bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size); 2120 bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size);
2109 p += XSTRING (tem)->size; 2121 p += XSTRING (tem)->size;
2122 tem = overlay_heads.buf[i].string2;
2123 if (STRINGP (tem))
2124 {
2125 bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size);
2126 p += XSTRING (tem)->size;
2127 }
2110 } 2128 }
2129 if (p != overlay_str_buf + total)
2130 abort ();
2111 if (pstr) 2131 if (pstr)
2112 *pstr = overlay_str_buf; 2132 *pstr = overlay_str_buf;
2113 return total; 2133 return total;