commit 99120491730c5839a5ba15ded187d481af1e71a7 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Fri Jan 13 19:32:47 2023 -0800 Update from Gnulib by running admin/merge-gnulib This adds a new file m4/xattr.m4 from Gnulib, for NFS v4 attribute copying. Also, do these changes by hand: * configure.ac: Mention $LIB_XATTR" in ACL summary. * src/Makefile.in (QCOPY_ACL_LIB): New macro. (LIBES): Use it. diff --git a/build-aux/update-copyright b/build-aux/update-copyright index ce919bac727..99196fceef6 100755 --- a/build-aux/update-copyright +++ b/build-aux/update-copyright @@ -137,7 +137,7 @@ eval 'exec perl -wSx -0777 -pi "$0" "$@"' if 0; -my $VERSION = '2020-04-04.15:07'; # UTC +my $VERSION = '2023-01-11.04:24'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook @@ -280,7 +280,7 @@ if (defined $stmt_re) } # Replace the old copyright statement. - s/$stmt_re/$stmt_wrapped/; + s/$stmt_re/$stmt_wrapped/g; } } else diff --git a/configure.ac b/configure.ac index 8c11414fe0b..d7aec4414e3 100644 --- a/configure.ac +++ b/configure.ac @@ -6553,7 +6553,9 @@ AC_DEFUN fi if test $USE_ACL -ne 0; then - ACL_SUMMARY="yes $LIB_ACL" + ACL_SUMMARY="yes" + test "$LIB_ACL" && ACL_SUMMARY="$ACL_SUMMARY $LIB_ACL" + test "$LIB_XATTR" && ACL_SUMMARY="$ACL_SUMMARY $LIB_XATTR" else ACL_SUMMARY=no fi diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 2ebf187e867..2097850c812 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -949,6 +949,7 @@ LIB_PTHREAD = @LIB_PTHREAD@ LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ LIB_TIMER_TIME = @LIB_TIMER_TIME@ LIB_WSOCK32 = @LIB_WSOCK32@ +LIB_XATTR = @LIB_XATTR@ LIMITS_H = @LIMITS_H@ LN_S_FILEONLY = @LN_S_FILEONLY@ LTLIBGMP = @LTLIBGMP@ @@ -1041,6 +1042,7 @@ PROFILING_CFLAGS = @PROFILING_CFLAGS@ PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ PTHREAD_SIGMASK_LIB = @PTHREAD_SIGMASK_LIB@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ +QCOPY_ACL_LIB = @QCOPY_ACL_LIB@ RALLOC_OBJ = @RALLOC_OBJ@ RANLIB = @RANLIB@ REPLACE_ACCESS = @REPLACE_ACCESS@ diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c index 883bcf7d588..0f4159b7fd9 100644 --- a/lib/qcopy-acl.c +++ b/lib/qcopy-acl.c @@ -23,6 +23,20 @@ #include "acl-internal.h" +#if USE_XATTR + +# include + +/* Returns 1 if NAME is the name of an extended attribute that is related + to permissions, i.e. ACLs. Returns 0 otherwise. */ + +static int +is_attr_permissions (const char *name, struct error_context *ctx) +{ + return attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS; +} + +#endif /* USE_XATTR */ /* Copy access control lists from one file to another. If SOURCE_DESC is a valid file descriptor, use file descriptor operations, else use @@ -39,13 +53,33 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, int dest_desc, mode_t mode) { - struct permission_context ctx; int ret; +#ifdef USE_XATTR + /* in case no ACLs present and also to set higher mode bits + we chmod before setting ACLs as doing it after could overwrite them + (especially true for NFSv4, posix ACL has that ugly "mask" hack that + nobody understands) */ + ret = chmod_or_fchmod (dst_name, dest_desc, mode); + /* Rather than fiddling with acls one by one, we just copy the whole ACL xattrs + (Posix or NFSv4). Of course, that won't address ACLs conversion + (i.e. posix <-> nfs4) but we can't do it anyway, so for now, we don't care + Functions attr_copy_* return 0 in case we copied something OR nothing + to copy */ + if (ret == 0) + ret = source_desc <= 0 || dest_desc <= 0 + ? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL) + : attr_copy_fd (src_name, source_desc, dst_name, dest_desc, + is_attr_permissions, NULL); +#else + /* no XATTR, so we proceed the old dusty way */ + struct permission_context ctx; + ret = get_permissions (src_name, source_desc, mode, &ctx); if (ret != 0) return -2; ret = set_permissions (&ctx, dst_name, dest_desc); free_permission_context (&ctx); +#endif return ret; } diff --git a/lib/verify.h b/lib/verify.h index 17d6e78c816..b63cb264321 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -258,7 +258,9 @@ #define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ /* @assert.h omit start@ */ -#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) +#if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_TRAP 0 +#elif 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) # define _GL_HAS_BUILTIN_TRAP 1 #elif defined __has_builtin # define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap) @@ -266,7 +268,9 @@ #define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ # define _GL_HAS_BUILTIN_TRAP 0 #endif -#if 4 < __GNUC__ + (5 <= __GNUC_MINOR__) +#if defined __clang_major__ && __clang_major__ < 5 +# define _GL_HAS_BUILTIN_UNREACHABLE 0 +#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) # define _GL_HAS_BUILTIN_UNREACHABLE 1 #elif defined __has_builtin # define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) diff --git a/m4/acl.m4 b/m4/acl.m4 index e612f1ae34b..dc9853a156d 100644 --- a/m4/acl.m4 +++ b/m4/acl.m4 @@ -1,5 +1,5 @@ # acl.m4 - check for access control list (ACL) primitives -# serial 26 +# serial 27 # Copyright (C) 2002, 2004-2023 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -17,7 +17,7 @@ AC_DEFUN ]) -AC_DEFUN([gl_FUNC_ACL], +AC_DEFUN_ONCE([gl_FUNC_ACL], [ AC_REQUIRE([gl_FUNC_ACL_ARG]) AC_CHECK_FUNCS_ONCE([fchmod]) diff --git a/m4/assert_h.m4 b/m4/assert_h.m4 index 6275f633a69..3801452ef0d 100644 --- a/m4/assert_h.m4 +++ b/m4/assert_h.m4 @@ -18,7 +18,7 @@ AC_DEFUN [AC_LANG_PROGRAM( [[#if defined __clang__ && __STDC_VERSION__ < 202311 #pragma clang diagnostic error "-Wc2x-extensions" - #pragma clang diagnostic error "-Wc++17-extensions" + #pragma clang diagnostic error "-Wc++1z-extensions" #endif #ifdef INCLUDE_ASSERT_H #include @@ -60,7 +60,7 @@ AC_DEFUN /* Solaris 11.4 defines static_assert as a macro with 2 arguments. We need it also to be invocable with a single argument. */ #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus - #undef static_assert + #undef/**/static_assert #define static_assert _Static_assert #endif #endif]) diff --git a/m4/gettime.m4 b/m4/gettime.m4 index 06f32fe26c2..7e353fcd00e 100644 --- a/m4/gettime.m4 +++ b/m4/gettime.m4 @@ -1,4 +1,4 @@ -# gettime.m4 serial 12 +# gettime.m4 serial 13 dnl Copyright (C) 2002, 2004-2006, 2009-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -26,17 +26,24 @@ AC_DEFUN dnl We can't use AC_CHECK_FUNC here, because timespec_get() is defined as a dnl static inline function in on MSVC 14. - AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include - struct timespec ts; - ]], - [[return timespec_get (&ts, 0);]]) - ], - [gl_cv_func_timespec_get=yes], - [gl_cv_func_timespec_get=no]) - ]) + dnl But at the same time, we need to notice a missing declaration, like + dnl gl_CHECK_FUNCS_ANDROID does. + AC_CHECK_DECL([timespec_get], , , [[#include ]]) + if test $ac_cv_have_decl_timespec_get = yes; then + AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + struct timespec ts; + ]], + [[return timespec_get (&ts, 0);]]) + ], + [gl_cv_func_timespec_get=yes], + [gl_cv_func_timespec_get=no]) + ]) + else + gl_cv_func_timespec_get=no + fi ]) AC_DEFUN([gl_GETTIME_RES], diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 26239caa2b1..2db3376b01e 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -71,7 +71,7 @@ AC_DEFUN && (!defined __clang_minor__ \ || (defined __apple_build_version__ \ ? 6000000 <= __apple_build_version__ \ - : 3 < __clang_major__ + (5 <= __clang_minor__)))) + : 5 <= __clang_major__))) # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) #else # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index ae5001c44b5..10c74fa2392 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -456,6 +456,14 @@ AC_DEFUN gl_PREREQ_PTHREAD_SIGMASK ]) gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) + gl_FUNC_XATTR + AC_REQUIRE([gl_FUNC_ACL]) + if test "$use_xattr" = yes; then + QCOPY_ACL_LIB="$LIB_XATTR" + else + QCOPY_ACL_LIB="$LIB_ACL" + fi + AC_SUBST([QCOPY_ACL_LIB]) gl_FUNC_READLINK gl_CONDITIONAL([GL_COND_OBJ_READLINK], [test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1]) @@ -1543,5 +1551,6 @@ AC_DEFUN m4/warnings.m4 m4/wchar_t.m4 m4/wint_t.m4 + m4/xattr.m4 m4/zzgnulib.m4 ]) diff --git a/m4/utimens.m4 b/m4/utimens.m4 index ae35ef789b8..c5d9b69e6f5 100644 --- a/m4/utimens.m4 +++ b/m4/utimens.m4 @@ -3,7 +3,7 @@ dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl serial 11 +dnl serial 12 AC_DEFUN([gl_UTIMENS], [ @@ -11,7 +11,9 @@ AC_DEFUN AC_REQUIRE([gl_FUNC_UTIMES]) AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CHECK_FUNCS_ONCE([futimes futimesat futimens utimensat lutimes]) + AC_CHECK_FUNCS_ONCE([futimens utimensat lutimes]) + gl_CHECK_FUNCS_ANDROID([futimes], [[#include ]]) + gl_CHECK_FUNCS_ANDROID([futimesat], [[#include ]]) if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time). It is not diff --git a/m4/xattr.m4 b/m4/xattr.m4 new file mode 100644 index 00000000000..6141515652a --- /dev/null +++ b/m4/xattr.m4 @@ -0,0 +1,43 @@ +# xattr.m4 - check for Extended Attributes (Linux) +# serial 5 + +# Copyright (C) 2003-2023 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_XATTR], +[ + AC_ARG_ENABLE([xattr], + AS_HELP_STRING([--disable-xattr], + [do not support extended attributes]), + [use_xattr=$enableval], [use_xattr=yes]) + + LIB_XATTR= + AC_SUBST([LIB_XATTR]) + + if test "$use_xattr" = yes; then + AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h]) + use_xattr=no + if test "$ac_cv_header_attr_libattr_h" = yes \ + && test "$ac_cv_header_attr_error_context_h" = yes; then + xattr_saved_LIBS=$LIBS + AC_SEARCH_LIBS([attr_copy_file], [attr], + [test "$ac_cv_search_attr_copy_file" = "none required" || + LIB_XATTR="$ac_cv_search_attr_copy_file"]) + AC_CHECK_FUNCS([attr_copy_file]) + LIBS=$xattr_saved_LIBS + if test "$ac_cv_func_attr_copy_file" = yes; then + use_xattr=yes + fi + fi + if test $use_xattr = no; then + AC_MSG_WARN([libattr development library was not found or not usable.]) + AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.]) + fi + fi + if test "$use_xattr" = yes; then + AC_DEFINE([USE_XATTR], [1], + [Define to 1 to use the Linux extended attributes library.]) + fi +]) diff --git a/src/Makefile.in b/src/Makefile.in index 1a2a316b310..e08e5eead28 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -147,6 +147,7 @@ LIB_ACL= CLOCK_TIME_LIB=@CLOCK_TIME_LIB@ EUIDACCESS_LIBGEN=@EUIDACCESS_LIBGEN@ NANOSLEEP_LIB=@NANOSLEEP_LIB@ +QCOPY_ACL_LIB=@QCOPY_ACL_LIB@ LIB_TIMER_TIME=@LIB_TIMER_TIME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -559,7 +560,7 @@ lisp = LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(PGTK_LIBS) $(LIBX_BASE) $(LIBIMAGE) \ $(LIBX_OTHER) $(LIBSOUND) \ $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(CLOCK_TIME_LIB) \ - $(NANOSLEEP_LIB) $(WEBKIT_LIBS) \ + $(NANOSLEEP_LIB) $(QCOPY_ACL_LIB) $(WEBKIT_LIBS) \ $(EUIDACCESS_LIBGEN) $(LIB_TIMER_TIME) $(DBUS_LIBS) \ $(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \ $(XDBE_LIBS) $(XSYNC_LIBS) \ commit dce42f556177e4e0f15daccb3c2f27a47f2beebb Author: Stefan Monnier Date: Fri Jan 13 18:00:29 2023 -0500 * lisp/apropos.el (apropos-safe-documentation): Use `function-documentation` diff --git a/lisp/apropos.el b/lisp/apropos.el index b260d889955..9b9615221ca 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -1117,23 +1117,13 @@ apropos-documentation-check-elc-file (defun apropos-safe-documentation (function) "Like `documentation', except it avoids calling `get_doc_string'. Will return nil instead." - (while (and function (symbolp function)) - (setq function (symbol-function function))) - (if (eq (car-safe function) 'macro) - (setq function (cdr function))) - (setq function (if (byte-code-function-p function) - (if (> (length function) 4) - (aref function 4)) - (if (autoloadp function) - (nth 2 function) - (if (eq (car-safe function) 'lambda) - (if (stringp (nth 2 function)) - (nth 2 function) - (if (stringp (nth 3 function)) - (nth 3 function))))))) - (if (integerp function) - nil - function)) + (when (setq function (indirect-function function)) + ;; FIXME: `function-documentation' says not to call it, but `documentation' + ;; would turn (FILE . POS) references into strings too eagerly, so + ;; we do want to use the lower-level function. + (let ((doc (function-documentation function))) + ;; Docstrings from the DOC file are handled elsewhere. + (if (integerp doc) nil doc)))) (defcustom apropos-compact-layout nil "If non-nil, use a single line per binding." commit f5d8aa6edacc8f4d06bb78010e408034b83f98e0 Author: Stefan Monnier Date: Fri Jan 13 17:56:04 2023 -0500 (function-documentation): Make it work for the remaining cases * lisp/simple.el (function-documentation): Use `internal-subr-documentation` and make it work also with symbols and macros. * src/doc.c (Fsubr_documentation): New function, extracted from Fdocumentation. (syms_of_doc): defsubr it. (Fdocumentation): Don't handle subrs and module functions here. diff --git a/lisp/simple.el b/lisp/simple.el index f5712177234..eedc5d7244e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2709,7 +2709,16 @@ function-documentation (let ((doc (car body))) (when (funcall docstring-p doc) doc))) - (_ (signal 'invalid-function (list function)))))) + ((pred symbolp) + (let ((f (indirect-function function))) + (if f (function-documentation f) + (signal 'void-function (list function))))) + (`(macro . ,f) (function-documentation f)) + (_ + (let ((doc (internal-subr-documentation function))) + (if (eq t doc) + (signal 'invalid-function (list function)) + doc)))))) (cl-defmethod function-documentation ((function accessor)) (oclosure--accessor-docstring function)) ;; FIXME: η-reduce! diff --git a/src/doc.c b/src/doc.c index df57f84603e..174341523d7 100644 --- a/src/doc.c +++ b/src/doc.c @@ -330,19 +330,7 @@ DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, xsignal1 (Qvoid_function, function); if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) fun = XCDR (fun); -#ifdef HAVE_NATIVE_COMP - if (!NILP (Fsubr_native_elisp_p (fun))) - doc = native_function_doc (fun); - else -#endif - if (SUBRP (fun)) - doc = make_fixnum (XSUBR (fun)->doc); -#ifdef HAVE_MODULES - else if (MODULE_FUNCTIONP (fun)) - doc = module_function_documentation (XMODULE_FUNCTION (fun)); -#endif - else - doc = call1 (Qfunction_documentation, fun); + doc = call1 (Qfunction_documentation, fun); /* If DOC is 0, it's typically because of a dumped file missing from the DOC file (bug in src/Makefile.in). */ @@ -371,6 +359,25 @@ DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, return doc; } +DEFUN ("internal-subr-documentation", Fsubr_documentation, Ssubr_documentation, 1, 1, 0, + doc: /* Return the raw documentation info of a C primitive. */) + (Lisp_Object function) +{ +#ifdef HAVE_NATIVE_COMP + if (!NILP (Fsubr_native_elisp_p (function))) + return native_function_doc (function); + else +#endif + if (SUBRP (function)) + return make_fixnum (XSUBR (function)->doc); +#ifdef HAVE_MODULES + else if (MODULE_FUNCTIONP (function)) + return module_function_documentation (XMODULE_FUNCTION (function)); +#endif + else + return Qt; +} + DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 3, 0, doc: /* Return the documentation string that is SYMBOL's PROP property. @@ -713,6 +720,7 @@ syms_of_doc (void) /* Initialized by ‘main’. */ defsubr (&Sdocumentation); + defsubr (&Ssubr_documentation); defsubr (&Sdocumentation_property); defsubr (&Ssnarf_documentation); defsubr (&Stext_quoting_style); commit f56fea2fcc0a3fbb261628ad887a0bbee72820e3 Author: Stefan Monnier Date: Fri Jan 13 17:52:23 2023 -0500 * lisp/reveal.el (reveal-open-new-overlays): Use `invisible-p` diff --git a/lisp/reveal.el b/lisp/reveal.el index 8a1239e1aa2..5ebc5f7c6c3 100644 --- a/lisp/reveal.el +++ b/lisp/reveal.el @@ -118,17 +118,13 @@ reveal-open-new-overlays ;; overlay. Always reveal invisible text, but only reveal ;; display properties if `reveal-toggle-invisible' is ;; present. - (let ((inv (overlay-get ol 'invisible)) - (disp (and (overlay-get ol 'display) - (overlay-get ol 'reveal-toggle-invisible))) - open) - (when (and (or (and inv - ;; There's an `invisible' property. - ;; Make sure it's actually invisible, - ;; and ellipsized. - (and (consp buffer-invisibility-spec) - (cdr (assq inv buffer-invisibility-spec)))) - disp) + (let* ((inv (overlay-get ol 'invisible)) + (disp (and (overlay-get ol 'display) + (overlay-get ol 'reveal-toggle-invisible))) + (hidden (invisible-p inv)) + (ellipsis (and hidden (not (eq t hidden)))) + open) + (when (and (or ellipsis disp) (or (setq open (or (overlay-get ol 'reveal-toggle-invisible) (and (symbolp inv) commit b2fda50178b8151c3fe707d1a1b6b11f0c1eca12 Author: Gregory Heytings Date: Fri Jan 13 17:43:31 2023 -0500 undo-tests.el: Tests for bug#60467 * test/src/undo-tests.el (undo-test-combine-change-calls-1) (undo-test-combine-change-calls-2, undo-test-combine-change-calls-3): New tests. diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el index 84151d3b5db..fd45a9101fa 100644 --- a/test/src/undo-tests.el +++ b/test/src/undo-tests.el @@ -439,6 +439,78 @@ undo-test-region-mark-adjustment (should (string= (buffer-string) "aaaFirst line\nSecond line\nbbb")))) +(ert-deftest undo-test-combine-change-calls-1 () + "Test how `combine-change-calls' updates `buffer-undo-list'. +Case 1: a file-visiting buffer with `buffer-undo-list' non-nil +and `buffer-modified-p' non-nil when `combine-change-calls' is +called." + (ert-with-temp-file tempfile + (with-current-buffer (find-file tempfile) + (insert "A") + (undo-boundary) + (insert "B") + (undo-boundary) + (insert "C") + (undo-boundary) + (insert " ") + (undo-boundary) + (insert "D") + (undo-boundary) + (insert "E") + (undo-boundary) + (insert "F") + (should (= (length buffer-undo-list) 14)) + (goto-char (point-min)) + (combine-change-calls (point-min) (point-max) + (re-search-forward "ABC ") + (replace-match "Z ")) + (should (= (length buffer-undo-list) 15))))) + +(ert-deftest undo-test-combine-change-calls-2 () + "Test how `combine-change-calls' updates `buffer-undo-list'. +Case 2: a file-visiting buffer with `buffer-undo-list' non-nil +and `buffer-modified-p' nil when `combine-change-calls' is +called." + (ert-with-temp-file tempfile + (with-current-buffer (find-file tempfile) + (insert "A") + (undo-boundary) + (insert "B") + (undo-boundary) + (insert "C") + (undo-boundary) + (insert " ") + (undo-boundary) + (insert "D") + (undo-boundary) + (insert "E") + (undo-boundary) + (insert "F") + (should (= (length buffer-undo-list) 14)) + (save-buffer) + (goto-char (point-min)) + (combine-change-calls (point-min) (point-max) + (re-search-forward "ABC ") + (replace-match "Z ")) + (should (= (length buffer-undo-list) 15))))) + +(ert-deftest undo-test-combine-change-calls-3 () + "Test how `combine-change-calls' updates `buffer-undo-list'. +Case 3: a file-visiting buffer with `buffer-undo-list' nil and +`buffer-modified-p' nil when `combine-change-calls' is called." + (ert-with-temp-file tempfile + (with-current-buffer (find-file tempfile) + (insert "ABC DEF") + (save-buffer) + (kill-buffer)) + (with-current-buffer (find-file tempfile) + (should (= (length buffer-undo-list) 0)) + (goto-char (point-min)) + (combine-change-calls (point-min) (point-max) + (re-search-forward "ABC ") + (replace-match "Z ")) + (should (= (length buffer-undo-list) 1))))) + (defun undo-test-all (&optional interactive) "Run all tests for \\[undo]." (interactive "p") commit 977630b5285809a57e50ff5f38d9c34247b549a7 Author: Stefan Monnier Date: Fri Jan 13 17:41:37 2023 -0500 * lisp/subr.el (combine-change-calls-1): Fix bug#60467 Don't stop at timestamps. Also Don't burp about breakage just because (cdr old-bul) is nil. diff --git a/lisp/subr.el b/lisp/subr.el index d1d3c76caf8..9e50b1e7f91 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4966,21 +4966,20 @@ combine-change-calls-1 beg (marker-position end-marker) #'undo--wrap-and-run-primitive-undo - beg (marker-position end-marker) buffer-undo-list)) + beg (marker-position end-marker) + ;; We will truncate this list by side-effect below. + buffer-undo-list)) (ptr buffer-undo-list)) (if (not (eq buffer-undo-list old-bul)) (progn (while (and (not (eq (cdr ptr) old-bul)) ;; In case garbage collection has removed OLD-BUL. - (cdr ptr) - ;; Don't include a timestamp entry. - (not (and (consp (cdr ptr)) - (consp (cadr ptr)) - (eq (caadr ptr) t) - (setq old-bul (cdr ptr))))) + (or (cdr ptr) + (progn + (message "combine-change-calls: buffer-undo-list broken") + nil))) (setq ptr (cdr ptr))) - (unless (cdr ptr) - (message "combine-change-calls: buffer-undo-list broken")) + ;; Truncate the list that's in the `apply' entry. (setcdr ptr nil) (push ap-elt buffer-undo-list) (setcdr buffer-undo-list old-bul))))) commit f32ce2e38cfc99d869a3ae07e912d7ce33772f12 Author: Michael Albinus Date: Fri Jan 13 19:41:08 2023 +0100 Adapt tramp-tests.el * test/lisp/net/tramp-tests.el (tramp--test-container-p): Rename from `tramp--test-docker-p'. Handle also "podman" method. Adapt callees. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index dd3de27d3b9..918929f55e4 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -5469,7 +5469,7 @@ tramp-test32-shell-command (format "%s\n" (file-name-nondirectory tmp-name))) (should (string-match-p - ;; Some shells echo, for example the "adb" or "docker" methods. + ;; Some shells echo, for example the "adb" or container methods. (rx bos (** 1 2 (literal (file-name-nondirectory tmp-name)) "\n") eos) @@ -6567,11 +6567,12 @@ tramp--test-crypt-p "Check, whether the remote directory is encrypted." (tramp-crypt-file-name-p ert-remote-temporary-file-directory)) -(defun tramp--test-docker-p () - "Check, whether the docker method is used. +(defun tramp--test-container-p () + "Check, whether a container method is used. This does not support some special file names." - (string-equal - "docker" (file-remote-p ert-remote-temporary-file-directory 'method))) + (string-match-p + (rx bol (| "docker" "podman") eol) + (file-remote-p ert-remote-temporary-file-directory 'method))) (defun tramp--test-expensive-test-p () "Whether expensive tests are run. @@ -6945,7 +6946,7 @@ tramp-test41-special-characters (let ((files (list (cond ((or (tramp--test-ange-ftp-p) - (tramp--test-docker-p) + (tramp--test-container-p) (tramp--test-gvfs-p) (tramp--test-rclone-p) (tramp--test-sudoedit-p) @@ -7003,7 +7004,7 @@ tramp-test42-utf8 "Check UTF8 encoding in file names and file contents." (skip-unless (tramp--test-enabled)) (skip-unless (not (getenv "EMACS_HYDRA_CI"))) ; SLOW ~ 620s - (skip-unless (not (tramp--test-docker-p))) + (skip-unless (not (tramp--test-container-p))) (skip-unless (not (tramp--test-rsync-p))) (skip-unless (not (tramp--test-windows-nt-and-out-of-band-p))) (skip-unless (not (tramp--test-ksh-p))) @@ -7123,7 +7124,7 @@ tramp-test44-asynchronous-requests '(:unstable))) (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-supports-processes-p)) - (skip-unless (not (tramp--test-docker-p))) + (skip-unless (not (tramp--test-container-p))) (skip-unless (not (tramp--test-telnet-p))) (skip-unless (not (tramp--test-sshfs-p))) (skip-unless (not (tramp--test-windows-nt-p)))