Next: Inserting Text, Previous: Examining Buffer Contents, Up: Text [Contents][Index]
33.3 Comparing TextThis function lets you compare portions of the text in a buffer, without copying them into strings first.
This function lets you compare two substrings of the same buffer or two different buffers. The first three arguments specify one substring, giving a buffer (or a buffer name) and two positions within the buffer. The last three arguments specify the other substring in the same way. You can use nil
for buffer1, buffer2, or both to stand for the current buffer.
The value is negative if the first substring is less, positive if the first is greater, and zero if they are equal. The absolute value of the result is one plus the index of the first differing characters within the substrings.
This function ignores case when comparing characters if case-fold-search
is non-nil
. It always ignores text properties.
Suppose you have the text ‘foobarbar haha!rara!’ in the current buffer; then in this example the two substrings are ‘rbar ’ and ‘rara!’. The value is 2 because the first substring is greater at the second character.
(compare-buffer-substrings nil 6 11 nil 16 21) ⇒ 2
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4