aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorPhilipp Stephani2017-05-07 21:01:53 +0200
committerPhilipp Stephani2017-06-17 15:40:58 +0200
commitd682f0daa3c0bfdd5ee8ce0e9226353d505e85a9 (patch)
treeef0a6de2163d2f3c3c9bcb5012875e0018ef496f /m4
parent46279c1ea117bab75bdeccfd04703033c9e7d26d (diff)
downloademacs-d682f0daa3c0bfdd5ee8ce0e9226353d505e85a9.tar.gz
emacs-d682f0daa3c0bfdd5ee8ce0e9226353d505e85a9.zip
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 'm4')
-rw-r--r--m4/gnulib-comp.m46
-rw-r--r--m4/minmax.m444
2 files changed, 50 insertions, 0 deletions
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 8f53a990e34..1ac58e871cc 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -61,6 +61,7 @@ AC_DEFUN([gl_EARLY],
61 # Code from module crypto/sha1: 61 # Code from module crypto/sha1:
62 # Code from module crypto/sha256: 62 # Code from module crypto/sha256:
63 # Code from module crypto/sha512: 63 # Code from module crypto/sha512:
64 # Code from module diffseq:
64 # Code from module dirent: 65 # Code from module dirent:
65 # Code from module dirfd: 66 # Code from module dirfd:
66 # Code from module dosname: 67 # Code from module dosname:
@@ -105,6 +106,7 @@ AC_DEFUN([gl_EARLY],
105 # Code from module lstat: 106 # Code from module lstat:
106 # Code from module manywarnings: 107 # Code from module manywarnings:
107 # Code from module memrchr: 108 # Code from module memrchr:
109 # Code from module minmax:
108 # Code from module mkostemp: 110 # Code from module mkostemp:
109 # Code from module mktime: 111 # Code from module mktime:
110 # Code from module mktime-internal: 112 # Code from module mktime-internal:
@@ -289,6 +291,7 @@ AC_DEFUN([gl_INIT],
289 gl_PREREQ_MEMRCHR 291 gl_PREREQ_MEMRCHR
290 fi 292 fi
291 gl_STRING_MODULE_INDICATOR([memrchr]) 293 gl_STRING_MODULE_INDICATOR([memrchr])
294 gl_MINMAX
292 gl_FUNC_MKOSTEMP 295 gl_FUNC_MKOSTEMP
293 if test $HAVE_MKOSTEMP = 0; then 296 if test $HAVE_MKOSTEMP = 0; then
294 AC_LIBOBJ([mkostemp]) 297 AC_LIBOBJ([mkostemp])
@@ -821,6 +824,7 @@ AC_DEFUN([gl_FILE_LIST], [
821 lib/count-one-bits.h 824 lib/count-one-bits.h
822 lib/count-trailing-zeros.c 825 lib/count-trailing-zeros.c
823 lib/count-trailing-zeros.h 826 lib/count-trailing-zeros.h
827 lib/diffseq.h
824 lib/dirent.in.h 828 lib/dirent.in.h
825 lib/dirfd.c 829 lib/dirfd.c
826 lib/dosname.h 830 lib/dosname.h
@@ -875,6 +879,7 @@ AC_DEFUN([gl_FILE_LIST], [
875 lib/md5.c 879 lib/md5.c
876 lib/md5.h 880 lib/md5.h
877 lib/memrchr.c 881 lib/memrchr.c
882 lib/minmax.h
878 lib/mkostemp.c 883 lib/mkostemp.c
879 lib/mktime-internal.h 884 lib/mktime-internal.h
880 lib/mktime.c 885 lib/mktime.c
@@ -991,6 +996,7 @@ AC_DEFUN([gl_FILE_LIST], [
991 m4/manywarnings.m4 996 m4/manywarnings.m4
992 m4/md5.m4 997 m4/md5.m4
993 m4/memrchr.m4 998 m4/memrchr.m4
999 m4/minmax.m4
994 m4/mkostemp.m4 1000 m4/mkostemp.m4
995 m4/mktime.m4 1001 m4/mktime.m4
996 m4/multiarch.m4 1002 m4/multiarch.m4
diff --git a/m4/minmax.m4 b/m4/minmax.m4
new file mode 100644
index 00000000000..6845fce89c4
--- /dev/null
+++ b/m4/minmax.m4
@@ -0,0 +1,44 @@
1# minmax.m4 serial 4
2dnl Copyright (C) 2005, 2009-2017 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_PREREQ([2.53])
8
9AC_DEFUN([gl_MINMAX],
10[
11 AC_REQUIRE([gl_PREREQ_MINMAX])
12])
13
14# Prerequisites of lib/minmax.h.
15AC_DEFUN([gl_PREREQ_MINMAX],
16[
17 gl_MINMAX_IN_HEADER([limits.h])
18 gl_MINMAX_IN_HEADER([sys/param.h])
19])
20
21dnl gl_MINMAX_IN_HEADER(HEADER)
22dnl The parameter has to be a literal header name; it cannot be macro,
23dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
24dnl invocations with a literal macro name.)
25AC_DEFUN([gl_MINMAX_IN_HEADER],
26[
27 m4_pushdef([header], AS_TR_SH([$1]))
28 m4_pushdef([HEADER], AS_TR_CPP([$1]))
29 AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
30 [gl_cv_minmax_in_]header,
31 [AC_COMPILE_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[#include <$1>
34 int x = MIN (42, 17);]],
35 [[]])],
36 [gl_cv_minmax_in_]header[=yes],
37 [gl_cv_minmax_in_]header[=no])])
38 if test $gl_cv_minmax_in_[]header = yes; then
39 AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
40 [Define to 1 if <$1> defines the MIN and MAX macros.])
41 fi
42 m4_popdef([HEADER])
43 m4_popdef([header])
44])