diff options
author | Philipp Stephani <phst@google.com> | 2017-05-07 21:01:53 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2017-06-17 15:40:58 +0200 |
commit | d682f0daa3c0bfdd5ee8ce0e9226353d505e85a9 (patch) | |
tree | ef0a6de2163d2f3c3c9bcb5012875e0018ef496f /src/buffer.h | |
parent | 46279c1ea117bab75bdeccfd04703033c9e7d26d (diff) | |
download | emacs-d682f0daa3c0bfdd5ee8ce0e9226353d505e85a9.tar.gz |
Add command to replace buffer contents
Add a new command 'replace-buffer-contents' that uses the Myers diff
algorithm to non-destructively replace the accessible portion of the
current buffer. The Myers algorithm is implemented in Gnulib.
* src/editfns.c (Freplace_buffer_contents): New command.
(set_bit, bit_is_set, buffer_chars_equal): New helper functions.
(syms_of_editfns): Define new command.
* test/src/editfns-tests.el (replace-buffer-contents-1)
(replace-buffer-contents-2): New unit tests.
* src/buffer.h (BUF_FETCH_CHAR_AS_MULTIBYTE): New helper macro.
* admin/merge-gnulib (GNULIB_MODULES): Add diffseq.h and minmax.h.
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h index a2bdc4e7294..be270fe4823 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -412,6 +412,15 @@ extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); ? BUF_FETCH_MULTIBYTE_CHAR ((buf), (pos)) \ : BUF_FETCH_BYTE ((buf), (pos))) +/* Return character at byte position POS in buffer BUF. If BUF is + unibyte and the character is not ASCII, make the returning + character multibyte. */ + +#define BUF_FETCH_CHAR_AS_MULTIBYTE(buf, pos) \ + (! NILP (BVAR ((buf), enable_multibyte_characters)) \ + ? BUF_FETCH_MULTIBYTE_CHAR ((buf), (pos)) \ + : UNIBYTE_TO_CHAR (BUF_FETCH_BYTE ((buf), (pos)))) + /* Return the byte at byte position N in buffer BUF. */ #define BUF_FETCH_BYTE(buf, n) \ |