emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] feature/tramp-thread-safe 8db0de9: Merge branch 'master' i


From: Michael Albinus
Subject: [Emacs-diffs] feature/tramp-thread-safe 8db0de9: Merge branch 'master' into feature/tramp-thread-safe
Date: Sun, 5 Aug 2018 13:59:06 -0400 (EDT)

branch: feature/tramp-thread-safe
commit 8db0de97ac054366f2f0296d2665a2fcfd074d75
Merge: 33363e5 56683b1
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Merge branch 'master' into feature/tramp-thread-safe
---
 .gitignore                                         |   1 +
 admin/merge-gnulib                                 |   2 +-
 build-aux/config.guess                             |  36 +-
 build-aux/config.sub                               |   6 +-
 doc/emacs/dired.texi                               |   5 +
 doc/emacs/files.texi                               |   2 +
 doc/emacs/indent.texi                              |  21 +-
 doc/emacs/mule.texi                                |  19 +-
 doc/lispref/debugging.texi                         | 115 ++-
 doc/lispref/edebug.texi                            |  12 +-
 doc/lispref/eval.texi                              |   3 -
 doc/lispref/files.texi                             |   8 +-
 doc/lispref/frames.texi                            |  10 +-
 doc/lispref/minibuf.texi                           |   2 +-
 doc/lispref/numbers.texi                           |   2 +-
 doc/lispref/strings.texi                           |  19 +-
 doc/misc/ert.texi                                  |   8 +-
 doc/misc/flymake.texi                              |   2 +-
 doc/misc/tramp.texi                                |  74 +-
 etc/NEWS                                           |  93 ++-
 etc/emacs.service                                  |   2 +-
 lib-src/pop.c                                      |   8 +-
 lib/gnulib.mk.in                                   |  29 +
 lib/ieee754.in.h                                   | 222 +++++
 lisp/bookmark.el                                   |   7 +-
 lisp/calendar/todo-mode.el                         | 182 ++--
 lisp/dired-aux.el                                  |  37 +-
 lisp/dired.el                                      |   3 +
 lisp/emacs-lisp/backtrace.el                       | 916 +++++++++++++++++++++
 lisp/emacs-lisp/cl-macs.el                         |   5 +-
 lisp/emacs-lisp/cl-print.el                        | 297 ++++++-
 lisp/emacs-lisp/debug.el                           | 463 ++++-------
 lisp/emacs-lisp/edebug.el                          | 276 +++++--
 lisp/emacs-lisp/ert.el                             |  41 +-
 lisp/emacs-lisp/lisp-mode.el                       |  26 +-
 lisp/emacs-lisp/map-ynp.el                         |  18 +-
 lisp/eshell/em-dirs.el                             |   3 +
 lisp/eshell/em-ls.el                               |   1 +
 lisp/eshell/em-unix.el                             |  10 +
 lisp/eshell/esh-cmd.el                             |  51 +-
 lisp/eshell/esh-ext.el                             |   1 +
 lisp/files.el                                      |  17 +-
 lisp/gnus/gnus-sum.el                              |   8 +-
 lisp/international/fontset.el                      |   9 +-
 lisp/international/mule-cmds.el                    |   9 +-
 lisp/international/mule-conf.el                    |   9 +-
 lisp/international/mule-diag.el                    |   3 +-
 lisp/language/thai.el                              |   4 +-
 lisp/ldefs-boot.el                                 | 874 +++++++++++++-------
 lisp/mh-e/mh-comp.el                               | 100 ++-
 lisp/mh-e/mh-funcs.el                              |   2 +
 lisp/mh-e/mh-identity.el                           |  27 +
 lisp/net/tramp-gvfs.el                             |  37 +-
 lisp/net/tramp-sh.el                               |   6 +-
 lisp/net/tramp.el                                  |  12 +-
 lisp/progmodes/cc-engine.el                        |  12 +-
 lisp/progmodes/subword.el                          |   4 +-
 lisp/scroll-bar.el                                 |  24 +-
 lisp/shadowfile.el                                 |  36 +-
 lisp/simple.el                                     |  12 +-
 lisp/subr.el                                       |  31 +-
 lisp/term.el                                       |  20 +-
 lisp/thingatpt.el                                  |   2 +-
 lisp/vc/diff.el                                    |   5 +-
 lisp/w32-fns.el                                    |   2 +-
 lisp/wdired.el                                     |  51 +-
 m4/gnulib-comp.m4                                  |   4 +
 m4/ieee754-h.m4                                    |  21 +
 nt/inc/ms-w32.h                                    |  12 +-
 nt/inc/sys/socket.h                                |   5 +
 src/character.c                                    |  10 +-
 src/data.c                                         |   4 -
 src/editfns.c                                      |  64 +-
 src/emacs.c                                        |  11 +
 src/eval.c                                         |  20 +-
 src/fileio.c                                       |  15 +
 src/floatfns.c                                     |   7 -
 src/fns.c                                          |  23 +
 src/json.c                                         |   2 +-
 src/keyboard.c                                     |  28 +-
 src/lisp.h                                         |  13 +-
 src/lread.c                                        |  12 +-
 src/print.c                                        |  48 +-
 src/textprop.c                                     |  20 +-
 src/xdisp.c                                        |   3 +-
 test/lisp/calendar/todo-mode-tests.el              | 190 ++++-
 test/lisp/emacs-lisp/backtrace-tests.el            | 436 ++++++++++
 test/lisp/emacs-lisp/cl-print-tests.el             | 178 +++-
 .../edebug-resources/edebug-test-code.el           |   9 +-
 test/lisp/emacs-lisp/edebug-tests.el               |  29 +-
 test/lisp/emacs-lisp/ert-tests.el                  |   2 +-
 test/lisp/emacs-lisp/lisp-mode-tests.el            |  23 +
 test/lisp/filenotify-tests.el                      |   4 +-
 test/lisp/net/tramp-tests.el                       |  16 +-
 test/lisp/shadowfile-tests.el                      |  74 +-
 test/lisp/wdired-tests.el                          | 129 +++
 test/src/editfns-tests.el                          |  10 +-
 97 files changed, 4536 insertions(+), 1240 deletions(-)

diff --git a/.gitignore b/.gitignore
index d3712b0..26fe4bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ lib/execinfo.h
 lib/fcntl.h
 lib/getopt.h
 lib/getopt-cdefs.h
+lib/ieee754.h
 lib/inttypes.h
 lib/libgnu.a
 lib/limits.h
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 39dfaee..1397ecf 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -35,7 +35,7 @@ GNULIB_MODULES='
   fcntl fcntl-h fdatasync fdopendir
   filemode filevercmp flexmember fpieee fstatat fsusage fsync
   getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
-  ignore-value intprops largefile lstat
+  ieee754-h ignore-value intprops largefile lstat
   manywarnings memrchr minmax mkostemp mktime nstrftime
   pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat
   sig2str socklen stat-time std-gnu11 stdalign stddef stdio
diff --git a/build-aux/config.guess b/build-aux/config.guess
index ced991e..ba6af63 100755
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2018-07-13'
+timestamp='2018-07-18'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -392,20 +392,15 @@ case 
"$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
        echo i386-pc-auroraux"$UNAME_RELEASE"
        exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-       set_cc_for_build
-       SUN_ARCH=i386
-       # If there is a compiler, see if it is configured for 64-bit objects.
-       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
-       # This test works for both compilers.
-       if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
-           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-               (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-               grep IS_64BIT_ARCH >/dev/null
-           then
-               SUN_ARCH=x86_64
-           fi
-       fi
-       echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
+       UNAME_REL="`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
+       case `isainfo -b` in
+           32)
+               echo i386-pc-solaris2"$UNAME_REL"
+               ;;
+           64)
+               echo x86_64-pc-solaris2"$UNAME_REL"
+               ;;
+       esac
        exit ;;
     sun4*:SunOS:6*:*)
        # According to config.sub, this is the proper way to canonicalize
@@ -843,6 +838,17 @@ EOF
     *:BSD/OS:*:*)
        echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
        exit ;;
+    arm*:FreeBSD:*:*)
+       UNAME_PROCESSOR=`uname -p`
+       set_cc_for_build
+       if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_PCS_VFP
+       then
+           echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo 
${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
+       else
+           echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo 
${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
+       fi
+       exit ;;
     *:FreeBSD:*:*)
        UNAME_PROCESSOR=`/usr/bin/uname -p`
        case "$UNAME_PROCESSOR" in
diff --git a/build-aux/config.sub b/build-aux/config.sub
index 64f9b14..52eb02e 100755
--- a/build-aux/config.sub
+++ b/build-aux/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2018-07-13'
+timestamp='2018-07-25'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -307,7 +307,7 @@ case $1 in
                                os=mach
                                ;;
                        vsta)
-                               basic_machine=i386-unknown
+                               basic_machine=i386-pc
                                os=vsta
                                ;;
                        isi68 | isi)
@@ -371,7 +371,7 @@ case $1 in
                                os=sysv4
                                ;;
                        netbsd386)
-                               basic_machine=i386-unknown
+                               basic_machine=i386-pc
                                os=netbsd
                                ;;
                        netwinder)
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 007a943..1b03a39 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -1468,6 +1468,11 @@ rotation is lossless, and uses an external utility called
 directory's name, and creates that directory.  It signals an error if
 the directory already exists.
 
address@hidden dired-create-empty-file
+  The command (@code{dired-create-empty-file}) reads a
+file name, and creates that file.  It signals an error if
+the file already exists.
+
 @cindex searching multiple files via Dired
 @kindex M-s a C-s @r{(Dired)}
 @kindex M-s a M-C-s @r{(Dired)}
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index a11d8b9..197cceb 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -909,6 +909,8 @@ You can answer ``no'' to bypass copying of this file, this 
time.  If
 you want to cancel the shadowing permanently for a certain file, use
 @address@hidden shadow-cancel}} to eliminate or change the shadow file group.
 
+File Shadowing is not available on MS Windows.
+
 @node Time Stamps
 @subsection Updating Time Stamps Automatically
 @cindex time stamps
diff --git a/doc/emacs/indent.texi b/doc/emacs/indent.texi
index b38e858..bf43909 100644
--- a/doc/emacs/indent.texi
+++ b/doc/emacs/indent.texi
@@ -60,9 +60,9 @@ repositioned to the first non-whitespace character on the 
line.
 @node Indentation Commands
 @section Indentation Commands
 
-Apart from the @key{TAB} (@code{indent-for-tab-command}) command,
-Emacs provides a variety of commands to perform indentation in other
-ways.
+Apart from the @address@hidden (@code{indent-for-tab-command})
+command, Emacs provides a variety of commands to perform indentation
+in other ways.
 
 @table @kbd
 @item C-M-o
@@ -113,8 +113,8 @@ appears after the newline that is deleted.  @xref{Fill 
Prefix}.
 @item C-M-\
 @kindex C-M-\
 @findex indent-region
-Indent all the lines in the region, as though you had typed @key{TAB}
-at the beginning of each line (@code{indent-region}).
+Indent all the lines in the region, as though you had typed
address@hidden@key{TAB}} at the beginning of each line (@code{indent-region}).
 
 If a numeric argument is supplied, indent every line in the region to
 that column number.
@@ -128,11 +128,12 @@ in the region, moving the affected lines as a rigid unit.
 
 If called with no argument, the command activates a transient mode for
 adjusting the indentation of the affected lines interactively.  While
-this transient mode is active, typing @key{LEFT} or @key{RIGHT}
-indents leftward and rightward, respectively, by one space.  You can
-also type @address@hidden or @address@hidden to indent leftward
-or rightward to the next tab stop (@pxref{Tab Stops}).  Typing any
-other key disables the transient mode, and resumes normal editing.
+this transient mode is active, typing @address@hidden or
address@hidden@key{RIGHT}} indents leftward and rightward, respectively, by one
+space.  You can also type @address@hidden or @address@hidden to
+indent leftward or rightward to the next tab stop (@pxref{Tab Stops}).
+Typing any other key disables the transient mode, and resumes normal
+editing.
 
 If called with a prefix argument @var{n}, this command indents the
 lines forward by @var{n} spaces (without enabling the transient mode).
diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi
index 401c83d..6c0c5b2 100644
--- a/doc/emacs/mule.texi
+++ b/doc/emacs/mule.texi
@@ -156,12 +156,19 @@ system encodes the character safely and with a single byte
 (@pxref{Coding Systems}).  If the character's encoding is longer than
 one byte, Emacs shows @samp{file ...}.
 
-  As a special case, if the character lies in the range 128 (0200
-octal) through 159 (0237 octal), it stands for a raw byte that
-does not correspond to any specific displayable character.  Such a
-character lies within the @code{eight-bit-control} character set,
-and is displayed as an escaped octal character code.  In this case,
address@hidden =} shows @samp{part of display ...} instead of @samp{file}.
address@hidden eight-bit character set
address@hidden raw bytes
+  On rare occasions, Emacs encounters @dfn{raw bytes}: single bytes
+whose values are in the range 128 (0200 octal) through 255 (0377
+octal), which Emacs cannot interpret as part of a known encoding of
+some non-ASCII character.  Such raw bytes are treated as if they
+belonged to a special character set @code{eight-bit}; Emacs displays
+them as escaped octal codes (this can be customized; @pxref{Display
+Custom}).  In this case, @kbd{C-x =} shows @samp{raw-byte} instead of
address@hidden  In addition, @kbd{C-x =} shows the character codes of
+raw bytes as if they were in the range @code{#x3FFF80..#x3FFFFF},
+which is where Emacs maps them to distinguish them from Unicode
+characters in the range @code{#x0080..#x00FF}.
 
 @cindex character set of character at point
 @cindex font of character at point
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 1b1f874..9b3ba6c 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -81,7 +81,8 @@ debugger recursively.  @xref{Recursive Editing}.
 * Function Debugging::    Entering it when a certain function is called.
 * Variable Debugging::    Entering it when a variable is modified.
 * Explicit Debug::        Entering it at a certain point in the program.
-* Using Debugger::        What the debugger does; what you see while in it.
+* Using Debugger::        What the debugger does.
+* Backtraces::            What you see while in the debugger.
 * Debugger Commands::     Commands used while in the debugger.
 * Invoking the Debugger:: How to call the function @code{debug}.
 * Internals of Debugger:: Subroutines of the debugger, and global variables.
@@ -392,32 +393,82 @@ this is not what you want, you can either set
 @code{eval-expression-debug-on-error} to @code{nil}, or set
 @code{debug-on-error} to @code{nil} in @code{debugger-mode-hook}.
 
+  The debugger itself must be run byte-compiled, since it makes
+assumptions about the state of the Lisp interpreter.  These
+assumptions are false if the debugger is running interpreted.
+
address@hidden Backtraces
address@hidden Backtraces
address@hidden backtrace buffer
+
+Debugger mode is derived from Backtrace mode, which is also used to
+show backtraces by Edebug and ERT.  (@pxref{Edebug}, and @ref{Top,the
+ERT manual,, ert, ERT: Emacs Lisp Regression Testing}.)
+
address@hidden stack frame
+The backtrace buffer shows you the functions that are executing and
+their argument values.  When a backtrace buffer is created, it shows
+each stack frame on one, possibly very long, line.  (A stack frame is
+the place where the Lisp interpreter records information about a
+particular invocation of a function.)  The most recently called
+function will be at the top.
+
 @cindex current stack frame
-  The backtrace buffer shows you the functions that are executing and
-their argument values.  It also allows you to specify a stack frame by
-moving point to the line describing that frame.  (A stack frame is the
-place where the Lisp interpreter records information about a particular
-invocation of a function.)  The frame whose line point is on is
-considered the @dfn{current frame}.  Some of the debugger commands
-operate on the current frame.  If a line starts with a star, that means
-that exiting that frame will call the debugger again.  This is useful
-for examining the return value of a function.
-
-  If a function name is underlined, that means the debugger knows
-where its source code is located.  You can click with the mouse on
-that name, or move to it and type @key{RET}, to visit the source code.
+In a backtrace you can specify a stack frame by moving point to a line
+describing that frame.  The frame whose line point is on is considered
+the @dfn{current frame}.
+
+If a function name is underlined, that means Emacs knows where its
+source code is located.  You can click with the mouse on that name, or
+move to it and type @key{RET}, to visit the source code.  You can also
+type @key{RET} while point is on any name of a function or variable
+which is not underlined, to see help information for that symbol in a
+help buffer, if any exists.  The @code{xref-find-definitions} command,
+bound to @key{M-.}, can also be used on any identifier in a backtrace
+(@pxref{Looking Up Identifiers,,,emacs, The GNU Emacs Manual}).
+
+In backtraces, the tails of long lists and the ends of long strings,
+vectors or structures, as well as objects which are deeply nested,
+will be printed as underlined ``...''.  You can click with the mouse
+on a ``...'', or type @key{RET} while point is on it, to show the part
+of the object that was hidden.  To control how much abbreviation is
+done, customize @code{backtrace-line-length}.
+
+Here is a list of commands for navigating and viewing backtraces:
 
-  The debugger itself must be run byte-compiled, since it makes
-assumptions about how many stack frames are used for the debugger
-itself.  These assumptions are false if the debugger is running
-interpreted.
address@hidden @kbd
address@hidden v
+Toggle the display of local variables of the current stack frame.
+
address@hidden p
+Move to the beginning of the frame, or to the beginning
+of the previous frame.
+
address@hidden n
+Move to the beginning of the next frame.
+
address@hidden +
+Add line breaks and indentation to the top-level Lisp form at point to
+make it more readable.
+
address@hidden -
+Collapse the top-level Lisp form at point back to a single line.
+
address@hidden #
+Toggle @code{print-circle} for the frame at point.
+
address@hidden .
+Expand all the forms abbreviated with ``...'' in the frame at point.
+
address@hidden table
 
 @node Debugger Commands
 @subsection Debugger Commands
 @cindex debugger command list
 
   The debugger buffer (in Debugger mode) provides special commands in
-addition to the usual Emacs commands.  The most important use of
+addition to the usual Emacs commands and to the Backtrace mode commands
+described in the previous section.  The most important use of
 debugger commands is for stepping through code, so that you can see
 how control flows.  The debugger can step through the control
 structures of an interpreted function, but cannot do so in a
@@ -427,6 +478,11 @@ the same function.  (To do this, visit the source for the 
function and
 type @kbd{C-M-x} on its definition.)  You cannot use the Lisp debugger
 to step through a primitive function.
 
+Some of the debugger commands operate on the current frame.  If a
+frame starts with a star, that means that exiting that frame will call the
+debugger again.  This is useful for examining the return value of a
+function.
+
 @c FIXME: Add @findex for the following commands?  --xfq
   Here is a list of Debugger mode commands:
 
@@ -502,8 +558,6 @@ Display a list of functions that will invoke the debugger 
when called.
 This is a list of functions that are set to break on entry by means of
 @code{debug-on-entry}.
 
address@hidden v
-Toggle the display of local variables of the current stack frame.
 @end table
 
 @node Invoking the Debugger
@@ -624,20 +678,19 @@ of @code{debug} (@pxref{Invoking the Debugger}).
 @cindex run time stack
 @cindex call stack
 This function prints a trace of Lisp function calls currently active.
-This is the function used by @code{debug} to fill up the
address@hidden buffer.  It is written in C, since it must have access
-to the stack to determine which function calls are active.  The return
-value is always @code{nil}.
+The trace is identical to the one that @code{debug} would show in the
address@hidden buffer.  The return value is always nil.
 
 In the following example, a Lisp expression calls @code{backtrace}
 explicitly.  This prints the backtrace to the stream
 @code{standard-output}, which, in this case, is the buffer
 @samp{backtrace-output}.
 
-Each line of the backtrace represents one function call.  The line shows
-the values of the function's arguments if they are all known; if they
-are still being computed, the line says so.  The arguments of special
-forms are elided.
+Each line of the backtrace represents one function call.  The line
+shows the function followed by a list of the values of the function's
+arguments if they are all known; if they are still being computed, the
+line consists of a list containing the function and its unevaluated
+arguments.  Long lists or deeply nested structures may be elided.
 
 @smallexample
 @group
@@ -654,7 +707,7 @@ forms are elided.
 @group
 ----------- Buffer: backtrace-output ------------
   backtrace()
-  (list ...computing arguments...)
+  (list 'testing (backtrace))
 @end group
   (progn ...)
   eval((progn (1+ var) (list 'testing (backtrace))))
@@ -685,7 +738,7 @@ example would look as follows:
 @group
 ----------- Buffer: backtrace-output ------------
   (backtrace)
-  (list ...computing arguments...)
+  (list 'testing (backtrace))
 @end group
   (progn ...)
   (eval (progn (1+ var) (list 'testing (backtrace))))
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi
index b9cc1d5..54200b9 100644
--- a/doc/lispref/edebug.texi
+++ b/doc/lispref/edebug.texi
@@ -442,8 +442,16 @@ Redisplay the most recently known expression result in the 
echo area
 Display a backtrace, excluding Edebug's own functions for clarity
 (@code{edebug-backtrace}).
 
-You cannot use debugger commands in the backtrace buffer in Edebug as
-you would in the standard debugger.
address@hidden, for a description of backtraces
+and the commands which work on them.
+
+If you would like to see Edebug's functions in the backtrace,
+use @kbd{M-x edebug-backtrace-show-instrumentation}.  To hide them
+again use @kbd{M-x edebug-backtrace-hide-instrumentation}.
+
+If a backtrace frame starts with @samp{>} that means that Edebug knows
+where the source code for the frame is located.  Use @kbd{s} to jump
+to the source code for the current frame.
 
 The backtrace buffer is killed automatically when you continue
 execution.
diff --git a/doc/lispref/eval.texi b/doc/lispref/eval.texi
index 4e8b0df..c9401be 100644
--- a/doc/lispref/eval.texi
+++ b/doc/lispref/eval.texi
@@ -507,9 +507,6 @@ Emacs Lisp with a reference to where each is described.
 @item setq-default
 @pxref{Creating Buffer-Local}
 
address@hidden track-mouse
address@hidden Tracking}
-
 @item unwind-protect
 @pxref{Nonlocal Exits}
 
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 4cb2605..2bbef8d 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -3022,10 +3022,16 @@ This command creates a directory named @var{dirname}.  
If
 @var{parents} is address@hidden, as is always the case in an
 interactive call, that means to create the parent directories first,
 if they don't already exist.
-
 @code{mkdir} is an alias for this.
 @end deffn
 
address@hidden Command make-empty-file filename &optional parents
+This command creates an empty file named @var{filename}.
+As @code{make-directory}, this command creates parent directories
+if @var{parents} is address@hidden
+If @var{filename} already exists, this command signals an error.
address@hidden deffn
+
 @deffn Command copy-directory dirname newname &optional keep-time parents 
copy-contents
 This command copies the directory named @var{dirname} to
 @var{newname}.  If @var{newname} is a directory name,
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 6678644..ba4b931 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -3373,10 +3373,10 @@ occur.  That is useful, because normally you don't want 
to track the
 mouse forever---only until some other event, such as the release of a
 button.
 
address@hidden track-mouse address@hidden
-This special form executes @var{body}, with generation of mouse motion
-events enabled.  Typically, @var{body} would use @code{read-event} to
-read the motion events and modify the display accordingly.  @xref{Motion
address@hidden track-mouse address@hidden
+This macro executes @var{body}, with generation of mouse motion events
+enabled.  Typically, @var{body} would use @code{read-event} to read
+the motion events and modify the display accordingly.  @xref{Motion
 Events}, for the format of mouse motion events.
 
 The value of @code{track-mouse} is that of the last form in @var{body}.
@@ -3396,7 +3396,7 @@ on (@pxref{Pointer Shape}).  Therefore, Lisp programs 
that need the
 mouse pointer to retain its original shape during dragging should bind
 @code{track-mouse} to the value @code{dragging} at the beginning of
 their @var{body}.
address@hidden defspec
address@hidden defmac
 
 The usual purpose of tracking mouse motion is to indicate on the screen
 the consequences of pushing or releasing a button at the current
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 889b64a..d091787 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -2199,7 +2199,7 @@ function @code{read-passwd}.
 @defun read-passwd prompt &optional confirm default
 This function reads a password, prompting with @var{prompt}.  It does
 not echo the password as the user types it; instead, it echoes
address@hidden  for each character in the password.  If you want to apply
address@hidden  for each character in the password.  If you want to apply
 another character to hide the password, let-bind the variable
 @code{read-hide-char} with that character.
 
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index 14d5059..a3317c9 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -241,7 +241,7 @@ A NaN is never numerically equal to any value, not even to 
itself.
 NaNs carry a sign and a significand, and non-numeric functions treat
 two NaNs as equal when their
 signs and significands agree.  Significands of NaNs are
-machine-dependent and are not directly visible to Emacs Lisp.
+machine-dependent, as are the digits in their string representation.
 
   When NaNs and signed zeros are involved, non-numeric functions like
 @code{eql}, @code{equal}, @code{sxhash-eql}, @code{sxhash-equal} and
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index f68199e..3558f17 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -922,7 +922,8 @@ Functions}).  Thus, strings are enclosed in @samp{"} 
characters, and
 @item %o
 @cindex integer to octal
 Replace the specification with the base-eight representation of an
-unsigned integer.  The object can also be a nonnegative floating-point
+integer.  Negative integers are formatted in a platform-dependent
+way.  The object can also be a nonnegative floating-point
 number that is formatted as an integer, dropping any fraction, if the
 integer does not exceed machine limits.
 
@@ -935,7 +936,8 @@ formatted as an integer, dropping any fraction.
 @itemx %X
 @cindex integer to hexadecimal
 Replace the specification with the base-sixteen representation of an
-unsigned integer.  @samp{%x} uses lower case and @samp{%X} uses upper
+integer.  Negative integers are formatted in a platform-dependent
+way.  @samp{%x} uses lower case and @samp{%X} uses upper
 case.  The object can also be a nonnegative floating-point number that
 is formatted as an integer, dropping any fraction, if the integer does
 not exceed machine limits.
@@ -1025,7 +1027,7 @@ both flags are used, @samp{+} takes precedence.
 
   The flag @samp{#} specifies an alternate form which depends on
 the format in use.  For @samp{%o}, it ensures that the result begins
-with a @samp{0}.  For @samp{%x} and @samp{%X}, it prefixes the result
+with a @samp{0}.  For @samp{%x} and @samp{%X}, it prefixes nonzero results
 with @samp{0x} or @samp{0X}.  For @samp{%e} and @samp{%f}, the
 @samp{#} flag means include a decimal point even if the precision is
 zero.  For @samp{%g}, it always includes a decimal point, and also
@@ -1108,6 +1110,17 @@ shows only the first three characters of the 
representation for
 precision is what the local library functions of the @code{printf}
 family produce.
 
address@hidden formatting numbers for rereading later
+  If you plan to use @code{read} later on the formatted string to
+retrieve a copy of the formatted value, use a specification that lets
address@hidden reconstruct the value.  To format numbers in this
+reversible way you can use @samp{%s} and @samp{%S}, to format just
+integers you can also use @samp{%d}, and to format just nonnegative
+integers you can also use @samp{#x%x} and @samp{#o%o}.  Other formats
+may be problematic; for example, @samp{%d} and @samp{%g} can mishandle
+NaNs and can lose precision and type, and @samp{#x%x} and @samp{#o%o}
+can mishandle negative integers.  @xref{Input Functions}.
+
 @node Case Conversion
 @section Case Conversion in Lisp
 @cindex upper case
diff --git a/doc/misc/ert.texi b/doc/misc/ert.texi
index 82e0e27..6a34f5c 100644
--- a/doc/misc/ert.texi
+++ b/doc/misc/ert.texi
@@ -273,9 +273,11 @@ moving point to it and typing @address@hidden jumps to its 
definition.
 @cindex backtrace of a failed test
 Pressing @kbd{r} re-runs the test near point on its own.  Pressing
 @kbd{d} re-runs it with the debugger enabled.  @kbd{.} jumps to the
-definition of the test near point (@address@hidden has the same effect if
-point is on the name of the test).  On a failed test, @kbd{b} shows
-the backtrace of the failure.
+definition of the test near point (@address@hidden has the same effect
+if point is on the name of the test).  On a failed test, @kbd{b} shows
+the backtrace of the failure.  @xref{Debugging,, Backtraces, elisp,
+GNU Emacs Lisp Reference Manual}, for more information about
+backtraces.
 
 @kindex address@hidden, in ert results buffer}
 @kbd{l} shows the list of @code{should} forms executed in the test.
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index bdefd40..bda7e14 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -4,7 +4,7 @@
 @set VERSION 1.0
 @set UPDATED June 2018
 @settitle GNU Flymake @value{VERSION}
address@hidden ../emacs/docstyle.texi
address@hidden docstyle.texi
 @syncodeindex pg cp
 @syncodeindex vr cp
 @syncodeindex fn cp
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 04002b7..fd188a7 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -544,9 +544,9 @@ file system), @address@hidden,user@@host,/path/to/file}} and
 @cindex method @option{gdrive}
 @cindex @option{gdrive} method
 @cindex google drive
address@hidden method @option{owncloud}
address@hidden @option{owncloud} method
address@hidden nextcloud
address@hidden method @option{nextcloud}
address@hidden @option{nextcloud} method
address@hidden owncloud
 
 GVFS-based methods include also @acronym{GNOME} Online Accounts, which
 support the @option{Files} service.  These are the Google Drive file
@@ -554,7 +554,7 @@ system, and the OwnCloud/NextCloud file system.  The file 
name syntax
 is here always
 @address@hidden,john.doe@@gmail.com,/path/to/file}}
 (@samp{john.doe@@gmail.com} stands here for your Google Drive
-account), or @address@hidden,user@@host#8081,/path/to/file}}
+account), or @address@hidden,user@@host#8081,/path/to/file}}
 (@samp{8081} stands for the port number) for OwnCloud/NextCloud files.
 
 
@@ -1096,7 +1096,7 @@ but with SSL encryption.  Both methods support the port 
numbers.
 
 Paths being part of the WebDAV volume to be mounted by GVFS, as it is
 common for OwnCloud or NextCloud file names, are not supported by
-these methods.  See method @option{owncloud} for handling them.
+these methods.  See method @option{nextcloud} for handling them.
 
 @item @option{gdrive}
 @cindex method @option{gdrive}
@@ -1114,13 +1114,13 @@ Since Google Drive uses cryptic blob file names 
internally,
 could produce unexpected behavior in case two files in the same
 directory have the same @code{display-name}, such a situation must be avoided.
 
address@hidden @option{owncloud}
address@hidden @option{nextcloud}
 @cindex @acronym{GNOME} Online Accounts
address@hidden method @option{owncloud}
address@hidden @option{owncloud} method
address@hidden nextcloud
address@hidden method @option{nextcloud}
address@hidden @option{nextcloud} method
address@hidden owncloud
 
-As the name indicates, the method @option{owncloud} allows you to
+As the name indicates, the method @option{nextcloud} allows you to
 access OwnCloud or NextCloud hosted files and directories.  Like the
 @option{gdrive} method, your credentials must be populated in your
 @command{Online Accounts} application outside Emacs. The method
@@ -1139,7 +1139,7 @@ that for security reasons refuse @command{ssh} 
connections.
 @defopt tramp-gvfs-methods
 This user option is a list of external methods for address@hidden  By default,
 this list includes @option{afp}, @option{dav}, @option{davs},
address@hidden, @option{owncloud} and @option{sftp}.  Other methods
address@hidden, @option{nextcloud} and @option{sftp}.  Other methods
 to include are @option{ftp}, @option{http}, @option{https} and
 @option{smb}.  These methods are not intended to be used directly as
 GVFS based method.  Instead, they are added here for the benefit of
@@ -1242,7 +1242,7 @@ improvement is not always true.
 @cindex default user
 
 @defopt tramp-default-user
address@hidden file name can omit the user name part since
+A @value{tramp} file name can omit the user name part since
 @value{tramp} substitutes the currently logged-in user name.  However
 this substitution can be overridden with @code{tramp-default-user}.
 For example:
@@ -1457,7 +1457,7 @@ support this command.
 
 @subsection Tunneling with ssh
 
-With ssh, you could use the @code{ProxyCommand} entry in the
+With ssh, you could use the @code{ProxyCommand} entry in
 @file{~/.ssh/config}:
 
 @example
@@ -1593,12 +1593,12 @@ A function dedicated to @file{/etc/hosts} for host 
names.
 @item @code{tramp-parse-passwd}
 @findex tramp-parse-passwd
 
-A function which parses @file{/etc/passwd} files for user names.
+A function which parses @file{/etc/passwd} for user names.
 
 @item @code{tramp-parse-etc-group}
 @findex tramp-parse-etc-group
 
-A function which parses @file{/etc/group} files for group names.
+A function which parses @file{/etc/group} for group names.
 
 @item @code{tramp-parse-netrc}
 @findex tramp-parse-netrc
@@ -2198,7 +2198,7 @@ of the secretfile is now owned by the user logged in from
 When @code{backup-directory-alist} is @code{nil} (the default), such
 problems do not occur.
 
-To ``turn off'' the backup feature for @value{tramp} files and stop
+To ``turn off'' the backup feature for remote files and stop
 @value{tramp} from saving to the backup directory, use this:
 
 @lisp
@@ -2260,12 +2260,11 @@ The backup file name of
 
 @vindex auto-save-file-name-transforms
 Just as for backup files, similar issues of file naming affect
-auto-saving @value{tramp} files.  Auto-saved files are saved in the
-directory specified by the user option
address@hidden  By default this is set to
-the local temporary directory.  But in some versions of Debian
-GNU/Linux, this points to the source directory where the Emacs was
-compiled.  Reset such values to a valid directory.
+auto-saving remote files.  Auto-saved files are saved in the directory
+specified by the user option @code{auto-save-file-name-transforms}.
+By default this is set to the local temporary directory.  But in some
+versions of Debian GNU/Linux, this points to the source directory
+where the Emacs was compiled.  Reset such values to a valid directory.
 
 Set @code{auto-save-file-name-transforms} to @code{nil} to save
 auto-saved files to the same directory as the original file.
@@ -2769,8 +2768,8 @@ hard-coded, fixed name.  Note that using @code{:0} for 
X11 display name
 here will not work as expected.
 
 An alternate approach is specify @code{ForwardX11 yes} or
address@hidden yes} in the file @file{~/.ssh/config} on the
-local host.
address@hidden yes} in @file{~/.ssh/config} on the local
+host.
 
 
 @subsection Running @code{shell} on a remote host
@@ -3450,6 +3449,19 @@ source "address@hidden@}/.iterm2_shell_integration.bash"
 @end group
 @end example
 
+And finally, bash's readline should not use key bindings like
address@hidden to commands.  Disable this in your @file{~/.inputrc}:
+
address@hidden
address@hidden
+$if term=dumb
+# Don't bind Control-J or it messes up @value{tramp}.
+$else
+"\C-j": next-history
+$endif
address@hidden group
address@hidden example
+
 @item
 Echoed characters after login
 
@@ -3586,13 +3598,13 @@ When testing, ensure the remote shell is the same shell
 How to get notified after @value{tramp} completes file transfers?
 
 Make Emacs beep after reading from or writing to the remote host with
-the following code in @file{~/.emacs} file.
+the following code in @file{~/.emacs}.
 
 @lisp
 @group
 (defadvice tramp-handle-write-region
   (after tramp-write-beep-advice activate)
-  "Make tramp beep after writing a file."
+  "Make @value{tramp} beep after writing a file."
   (interactive)
   (beep))
 @end group
@@ -3600,7 +3612,7 @@ the following code in @file{~/.emacs} file.
 @group
 (defadvice tramp-handle-do-copy-or-rename-file
   (after tramp-copy-beep-advice activate)
-  "Make tramp beep after copying a file."
+  "Make @value{tramp} beep after copying a file."
   (interactive)
   (beep))
 @end group
@@ -3608,7 +3620,7 @@ the following code in @file{~/.emacs} file.
 @group
 (defadvice tramp-handle-insert-file-contents
   (after tramp-insert-beep-advice activate)
-  "Make tramp beep after inserting a file."
+  "Make @value{tramp} beep after inserting a file."
   (interactive)
   (beep))
 @end group
@@ -3646,7 +3658,7 @@ then set them with a hook as follows:
 
 
 @item
-Why is @file{~/.sh_history} file on the remote host growing?
+Why is @file{~/.sh_history} on the remote host growing?
 
 @vindex tramp-histfile-override
 @vindex address@hidden, environment variable}
@@ -3667,7 +3679,7 @@ undesired results when using @command{bash} as remote 
shell.
 Another approach is to disable @value{tramp}'s handling of the
 @env{HISTFILE} at all by setting @code{tramp-histfile-override} to
 @code{nil}.  In this case, saving history could be turned off by
-putting this shell code in the @file{.bashrc} or @file{.kshrc} file:
+putting this shell code in @file{.bashrc} or @file{.kshrc}:
 
 @example
 @group
@@ -3684,7 +3696,7 @@ fi
 @end example
 
 For @option{ssh}-based method, add the following line to your
address@hidden/.ssh/environment} file:
address@hidden/.ssh/environment}:
 
 @example
 HISTFILE=/dev/null
diff --git a/etc/NEWS b/etc/NEWS
index ea363c4..36bee81 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -81,14 +81,24 @@ work right without some adjustment:
 - you can use the new 'package-quickstart' so activation of packages does not
   need to pay attention to 'package-load-list' or 'package-user-dir' any more.
 
+---
+** Emacs now notifies systemd when startup finishes or shutdown begins.
+Units that are ordered after 'emacs.service' will only be started
+after Emacs has finished initialization and is ready for use.
+(If your Emacs is installed in a non-standard location and you copied the
+emacs.service file to eg ~/.config/systemd/user/, you will need to copy
+the new version of the file again.)
+
 
 * Changes in Emacs 27.1
 
++++
+** The function 'read-passwd' uses '*' as default character to hide passwords.
+
 ---
 ** New variable 'xft-ignore-color-fonts'.
 Default t means don't try to load color fonts when using Xft, as they
 often cause crashes.  Set it to nil if you really need those fonts.
-(Bug#30874)
 
 ---
 ** The new option 'tooltip-resize-echo-area' avoids truncating tooltip text
@@ -175,6 +185,9 @@ This triggers to search the program on the remote host as 
indicated by
 
 * Editing Changes in Emacs 27.1
 
++++
+** New command 'make-empty-file'.
+
 ---
 ** New variable 'x-wait-for-event-timeout'.
 This controls how long Emacs will wait for updates to the graphical
@@ -221,6 +234,11 @@ the supported commands.
 
 * Changes in Specialized Modes and Packages in Emacs 27.1
 
++++
+** Dired
+
+*** New command 'dired-create-empty-file'.
+
 ** Change Logs and VC
 
 *** Recording ChangeLog entries doesn't require an actual file.
@@ -268,6 +286,11 @@ better emulate 'M-.' in both Bash and zsh, since the 
former counts
 from the beginning of the arguments, while the latter counts from the
 end.
 
+** Term
+
+---
+*** 'term-read-noecho' is now obsolete, use 'read-passwd' instead.
+
 ** Flymake
 
 +++
@@ -452,6 +475,14 @@ the shift key.
 *** Isearch now remembers the regexp-based search mode for words/symbols
 and case-sensitivity together with search strings in the search ring.
 
+** Debugger
+
++++
+*** The Lisp Debugger is now based on 'backtrace-mode'.
+Backtrace mode adds fontification and commands for changing the
+appearance of backtrace frames.  See the node "Backtraces" in the Elisp
+manual for documentation of the new mode and its commands.
+
 ** Edebug
 
 +++
@@ -461,14 +492,27 @@ using the new variables 'edebug-behavior-alist',
 'edebug-new-definition-function'.  Edebug's behavior can be changed
 globally or for individual definitions.
 
++++
+*** Edebug's backtrace buffer now uses 'backtrace-mode'.
+Backtrace mode adds fontification, links and commands for changing the
+appearance of backtrace frames.  See the node "Backtraces" in the Elisp
+manual for documentation of the new mode and its commands.
+
+The binding of 'd' in Edebug's keymap is now 'edebug-pop-to-backtrace'
+which replaces 'edebug-backtrace'.  Consequently Edebug's backtrace
+windows now behave like those of the Lisp Debugger and of ERT, in that
+when they appear they will be the selected window.
+
+The new 'backtrace-goto-source' command, bound to 's', works in
+Edebug's backtraces on backtrace frames whose source code has
+been instrumented by Edebug.
+
 ** Enhanced xterm support
 
 *** New variable 'xterm-set-window-title' controls whether Emacs sets
 the XTerm window title.  This feature is experimental and is disabled
 by default.
 
-** Gamegrid
-
 ** grep
 
 +++
@@ -485,6 +529,14 @@ The abbreviation can be disabled by the new option
 *** New variable 'ert-quiet' allows to make ERT output in batch mode
 less verbose by removing non-essential information.
 
++++
+*** ERT's backtrace buffer now uses 'backtrace-mode'.
+Backtrace mode adds fontification and commands for changing the
+appearance of backtrace frames.  See the node "Backtraces" in the Elisp
+manual for documentation of the new mode and its commands.
+
+** Gamegrid
+
 ---
 *** Gamegrid now determines its default glyph size based on display
 dimensions, instead of always using 16 pixels.  As a result, Tetris,
@@ -558,7 +610,7 @@ process.  It now accepts signals specified either by name 
or by its number.
 *** Tramp is now thread-safe.
 
 +++
-*** New connection method "owncloud", which allows to access OwnCloud
+*** New connection method "nextcloud", which allows to access OwnCloud
 or NextCloud hosted files and directories.
 
 +++
@@ -658,6 +710,13 @@ transport strategies as well as a separate API to use 
them.  A
 transport implementation for process-based communication, such as is
 used by the Language Server Protocol (LSP), is readily available.
 
++++
+** Backtrace mode improves viewing of Elisp backtraces.
+Backtrace mode adds pretty printing, fontification and ellipsis
+expansion to backtrace buffers produced by the Lisp debugger, Edebug
+and ERT.  See the node "Backtraces" in the Elisp manual for
+documentation of the new mode and its commands.
+
 
 * Incompatible Lisp Changes in Emacs 27.1
 
@@ -698,7 +757,7 @@ as new-style, bind the new variable 
'force-new-style-backquotes' to t.
 
 ** When formatting a floating-point number as an octal or hexadecimal
 integer, Emacs now signals an error if the number is too large for the
-implementation to format (Bug#30408).
+implementation to format.
 
 +++
 ** The Lisp reader now signals an overflow for plain decimal integers
@@ -707,7 +766,7 @@ reader silently converted them to floating-point numbers, 
and signaled
 overflow only for integers with a radix that are outside machine range.
 To get the old behavior, set the new, experimental variable
 read-integer-overflow-as-float to t and please email
address@hidden if you need that.  (Bug#30408).
address@hidden if you need that.
 
 ---
 ** Some functions and variables obsolete since Emacs 22 have been removed:
@@ -817,6 +876,15 @@ between two strings.
 ** 'print-quoted' now defaults to t, so if you want to see
 (quote x) instead of 'x you will have to bind it to nil where applicable.
 
++++
+** Numbers formatted via %o or %x may now be formatted as signed integers.
+This avoids problems in calls like (read (format "#x%x" -1)), and is
+more compatible with bignums, a planned feature.  To get this
+behavior, set the experimental variable binary-as-unsigned to nil,
+and if the new behavior breaks your code please email
address@hidden  Because %o and %x can now format signed
+integers, they now support the + and space flags.
+
 ** To avoid confusion caused by "smart quotes", the reader signals an
 error when reading Lisp symbols which begin with one of the following
 quotation characters: ‘’‛“”‟〞"'.  A symbol beginning with such a
@@ -841,12 +909,12 @@ The new variable 'comment-use-syntax-ppss' can be set to 
nil to recover the old
 behavior if needed.
 
 ** The 'server-name' and 'server-socket-dir' variables are set when a
-socket has been passed to Emacs (Bug#24218).
+socket has been passed to Emacs.
 
 ---
 ** The 'file-system-info' function is now available on all platforms.
 instead of just Microsoft platforms.  This fixes a 'get-free-disk-space'
-bug on OS X 10.8 and later (Bug#28639).
+bug on OS X 10.8 and later.
 
 +++
 ** 'memory-limit' now returns a better estimate of memory consumption.
@@ -868,6 +936,9 @@ Formerly, some of these functions ignored signs and 
significands of
 NaNs.  Now, all these functions treat NaN signs and significands as
 significant.  For example, (eql 0.0e+NaN -0.0e+NaN) now returns nil
 because the two NaNs have different signs; formerly it returned t.
+Also, Emacs now reads and prints NaN significands; e.g., if X is a
+NaN, (format "%s" X) now returns "0.0e+NaN", "1.0e+NaN", etc.,
+depending on X's significand.
 
 +++
 ** The function 'make-string' accepts an additional optional argument.
@@ -875,7 +946,7 @@ If the optional third argument is non-nil, 'make-string' 
will produce
 a multibyte string even if its second argument is an ASCII character.
 
 ** (format "%d" X) no longer mishandles a floating-point number X that
-does not fit in a machine integer (Bug#30408).
+does not fit in a machine integer.
 
 ** New JSON parsing and serialization functions 'json-serialize',
 'json-insert', 'json-parse-string', and 'json-parse-buffer'.  These
@@ -910,10 +981,6 @@ higher-level functions.
 some years back.  It now respects 'imagemagick-types-inhibit' as a way
 to disable that.
 
-+++
-** The new function 'read-answer' accepts either long or short answers
-depending on the new customizable variable 'read-answer-short'.
-
 ** The function 'load' now behaves correctly when loading modules.
 Specifically, it puts the module name into 'load-history', prints
 loading messages if requested, and protects against recursive loads.
diff --git a/etc/emacs.service b/etc/emacs.service
index b29177b..dbcb6bc 100644
--- a/etc/emacs.service
+++ b/etc/emacs.service
@@ -7,7 +7,7 @@ Description=Emacs text editor
 Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
 
 [Service]
-Type=simple
+Type=notify
 ExecStart=emacs --fg-daemon
 ExecStop=emacsclient --eval "(kill-emacs)"
 Environment=SSH_AUTH_SOCK=%t/keyring/ssh
diff --git a/lib-src/pop.c b/lib-src/pop.c
index 10aac95..731f951 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -30,8 +30,12 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "ntlib.h"
 #undef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501    /* for getaddrinfo stuff */
-#include <winsock2.h>
-#include <ws2tcpip.h>
+#if defined __MINGW32_VERSION && __MINGW32_VERSION >= 5000002L
+# include <windows.h>
+#else
+# include <winsock2.h>
+#endif
+# include <ws2tcpip.h>
 #undef getaddrinfo
 #define getaddrinfo  sys_getaddrinfo
 #undef freeaddrinfo
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index e623921..7d28dcc 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -95,6 +95,7 @@
 #  gettime \
 #  gettimeofday \
 #  gitlog-to-changelog \
+#  ieee754-h \
 #  ignore-value \
 #  intprops \
 #  largefile \
@@ -220,6 +221,7 @@ GL_GENERATE_ALLOCA_H = @GL_GENERATE_ALLOCA_H@
 GL_GENERATE_BYTESWAP_H = @GL_GENERATE_BYTESWAP_H@
 GL_GENERATE_ERRNO_H = @GL_GENERATE_ERRNO_H@
 GL_GENERATE_EXECINFO_H = @GL_GENERATE_EXECINFO_H@
+GL_GENERATE_IEEE754_H = @GL_GENERATE_IEEE754_H@
 GL_GENERATE_LIMITS_H = @GL_GENERATE_LIMITS_H@
 GL_GENERATE_STDALIGN_H = @GL_GENERATE_STDALIGN_H@
 GL_GENERATE_STDDEF_H = @GL_GENERATE_STDDEF_H@
@@ -646,6 +648,7 @@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@
 HAVE_XSERVER = @HAVE_XSERVER@
 HAVE__EXIT = @HAVE__EXIT@
 HYBRID_MALLOC = @HYBRID_MALLOC@
+IEEE754_H = @IEEE754_H@
 IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@
 IMAGEMAGICK_LIBS = @IMAGEMAGICK_LIBS@
 INCLUDE_NEXT = @INCLUDE_NEXT@
@@ -1787,6 +1790,32 @@ EXTRA_libgnu_a_SOURCES += group-member.c
 endif
 ## end   gnulib module group-member
 
+## begin gnulib module ieee754-h
+ifeq (,$(OMIT_GNULIB_MODULE_ieee754-h))
+
+BUILT_SOURCES += $(IEEE754_H)
+
+# We need the following in order to create <ieee754.h> when the system
+# doesn't have one that works with the given compiler.
+ifneq (,$(GL_GENERATE_IEEE754_H))
+ieee754.h: ieee754.in.h $(top_builddir)/config.status
+       $(AM_V_GEN)rm -f address@hidden && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/ifndef _GL_GNULIB_HEADER/if 0/g' \
+           $(srcdir)/ieee754.in.h; \
+       } > address@hidden && \
+       mv -f address@hidden $@
+else
+ieee754.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES += ieee754.h ieee754.h-t
+
+EXTRA_DIST += ieee754.in.h
+
+endif
+## end   gnulib module ieee754-h
+
 ## begin gnulib module ignore-value
 ifeq (,$(OMIT_GNULIB_MODULE_ignore-value))
 
diff --git a/lib/ieee754.in.h b/lib/ieee754.in.h
new file mode 100644
index 0000000..316ac03
--- /dev/null
+++ b/lib/ieee754.in.h
@@ -0,0 +1,222 @@
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _IEEE754_H
+
+#define _IEEE754_H 1
+
+#ifndef _GL_GNULIB_HEADER
+/* Ordinary glibc usage.  */
+# include <features.h>
+# include <endian.h>
+#else
+/* Gnulib usage.  */
+# ifndef __BEGIN_DECLS
+#  ifdef __cplusplus
+#   define __BEGIN_DECLS       extern "C" {
+#   define __END_DECLS         }
+#  else
+#   define __BEGIN_DECLS
+#   define __END_DECLS
+#  endif
+# endif
+# ifndef __FLOAT_WORD_ORDER
+#  define __LITTLE_ENDIAN      1234
+#  define __BIG_ENDIAN         4321
+#  ifdef WORDS_BIGENDIAN
+#   define __BYTE_ORDER __BIG_ENDIAN
+#  else
+#   define __BYTE_ORDER __LITTLE_ENDIAN
+#  endif
+#  define __FLOAT_WORD_ORDER __BYTE_ORDER
+# endif
+#endif
+
+__BEGIN_DECLS
+
+union ieee754_float
+  {
+    float f;
+
+    /* This is the IEEE 754 single-precision format.  */
+    struct
+      {
+#if    __BYTE_ORDER == __BIG_ENDIAN
+       unsigned int negative:1;
+       unsigned int exponent:8;
+       unsigned int mantissa:23;
+#endif                         /* Big endian.  */
+#if    __BYTE_ORDER == __LITTLE_ENDIAN
+       unsigned int mantissa:23;
+       unsigned int exponent:8;
+       unsigned int negative:1;
+#endif                         /* Little endian.  */
+      } ieee;
+
+    /* This format makes it easier to see if a NaN is a signalling NaN.  */
+    struct
+      {
+#if    __BYTE_ORDER == __BIG_ENDIAN
+       unsigned int negative:1;
+       unsigned int exponent:8;
+       unsigned int quiet_nan:1;
+       unsigned int mantissa:22;
+#endif                         /* Big endian.  */
+#if    __BYTE_ORDER == __LITTLE_ENDIAN
+       unsigned int mantissa:22;
+       unsigned int quiet_nan:1;
+       unsigned int exponent:8;
+       unsigned int negative:1;
+#endif                         /* Little endian.  */
+      } ieee_nan;
+  };
+
+#define IEEE754_FLOAT_BIAS     0x7f /* Added to exponent.  */
+
+
+union ieee754_double
+  {
+    double d;
+
+    /* This is the IEEE 754 double-precision format.  */
+    struct
+      {
+#if    __BYTE_ORDER == __BIG_ENDIAN
+       unsigned int negative:1;
+       unsigned int exponent:11;
+       /* Together these comprise the mantissa.  */
+       unsigned int mantissa0:20;
+       unsigned int mantissa1:32;
+#endif                         /* Big endian.  */
+#if    __BYTE_ORDER == __LITTLE_ENDIAN
+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
+       unsigned int mantissa0:20;
+       unsigned int exponent:11;
+       unsigned int negative:1;
+       unsigned int mantissa1:32;
+# else
+       /* Together these comprise the mantissa.  */
+       unsigned int mantissa1:32;
+       unsigned int mantissa0:20;
+       unsigned int exponent:11;
+       unsigned int negative:1;
+# endif
+#endif                         /* Little endian.  */
+      } ieee;
+
+    /* This format makes it easier to see if a NaN is a signalling NaN.  */
+    struct
+      {
+#if    __BYTE_ORDER == __BIG_ENDIAN
+       unsigned int negative:1;
+       unsigned int exponent:11;
+       unsigned int quiet_nan:1;
+       /* Together these comprise the mantissa.  */
+       unsigned int mantissa0:19;
+       unsigned int mantissa1:32;
+#else
+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
+       unsigned int mantissa0:19;
+       unsigned int quiet_nan:1;
+       unsigned int exponent:11;
+       unsigned int negative:1;
+       unsigned int mantissa1:32;
+# else
+       /* Together these comprise the mantissa.  */
+       unsigned int mantissa1:32;
+       unsigned int mantissa0:19;
+       unsigned int quiet_nan:1;
+       unsigned int exponent:11;
+       unsigned int negative:1;
+# endif
+#endif
+      } ieee_nan;
+  };
+
+#define IEEE754_DOUBLE_BIAS    0x3ff /* Added to exponent.  */
+
+
+union ieee854_long_double
+  {
+    long double d;
+
+    /* This is the IEEE 854 double-extended-precision format.  */
+    struct
+      {
+#if    __BYTE_ORDER == __BIG_ENDIAN
+       unsigned int negative:1;
+       unsigned int exponent:15;
+       unsigned int empty:16;
+       unsigned int mantissa0:32;
+       unsigned int mantissa1:32;
+#endif
+#if    __BYTE_ORDER == __LITTLE_ENDIAN
+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
+       unsigned int exponent:15;
+       unsigned int negative:1;
+       unsigned int empty:16;
+       unsigned int mantissa0:32;
+       unsigned int mantissa1:32;
+# else
+       unsigned int mantissa1:32;
+       unsigned int mantissa0:32;
+       unsigned int exponent:15;
+       unsigned int negative:1;
+       unsigned int empty:16;
+# endif
+#endif
+      } ieee;
+
+    /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
+    struct
+      {
+#if    __BYTE_ORDER == __BIG_ENDIAN
+       unsigned int negative:1;
+       unsigned int exponent:15;
+       unsigned int empty:16;
+       unsigned int one:1;
+       unsigned int quiet_nan:1;
+       unsigned int mantissa0:30;
+       unsigned int mantissa1:32;
+#endif
+#if    __BYTE_ORDER == __LITTLE_ENDIAN
+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
+       unsigned int exponent:15;
+       unsigned int negative:1;
+       unsigned int empty:16;
+       unsigned int mantissa0:30;
+       unsigned int quiet_nan:1;
+       unsigned int one:1;
+       unsigned int mantissa1:32;
+# else
+       unsigned int mantissa1:32;
+       unsigned int mantissa0:30;
+       unsigned int quiet_nan:1;
+       unsigned int one:1;
+       unsigned int exponent:15;
+       unsigned int negative:1;
+       unsigned int empty:16;
+# endif
+#endif
+      } ieee_nan;
+  };
+
+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
+
+__END_DECLS
+
+#endif /* ieee754.h */
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 78f3e32..58a2794 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1102,7 +1102,7 @@ BOOKMARK is usually a bookmark name (a string).  It can 
also be a
 bookmark record, but this is usually only done by programmatic callers.
 
 If DISPLAY-FUNC is non-nil, it is a function to invoke to display the
-bookmark.  It defaults to `switch-to-buffer'.  A typical value for
+bookmark.  It defaults to `pop-to-buffer-same-window'.  A typical value for
 DISPLAY-FUNC would be `switch-to-buffer-other-window'."
   (interactive
    (list (bookmark-completing-read "Jump to bookmark"
@@ -1110,7 +1110,10 @@ DISPLAY-FUNC would be `switch-to-buffer-other-window'."
   (unless bookmark
     (error "No bookmark specified"))
   (bookmark-maybe-historicize-string bookmark)
-  (bookmark--jump-via bookmark (or display-func 'switch-to-buffer)))
+  ;; Don't use `switch-to-buffer' because it would let the
+  ;; window-point override the bookmark's point when
+  ;; `switch-to-buffer-preserve-window-point' is non-nil.
+  (bookmark--jump-via bookmark (or display-func 'pop-to-buffer-same-window)))
 
 
 ;;;###autoload
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 5161ae8..6ff4d2a 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -853,17 +853,17 @@ category.  With non-nil argument BACK, visit the 
numerically
 previous category (the highest numbered one, if the current
 category is the first)."
   (interactive)
-  (setq todo-category-number
-        (1+ (mod (- todo-category-number (if back 2 0))
-                (length todo-categories))))
-  (when todo-skip-archived-categories
-    (while (and (zerop (todo-get-count 'todo))
-               (zerop (todo-get-count 'done))
-               (not (zerop (todo-get-count 'archived))))
-      (setq todo-category-number
-           (funcall (if back #'1- #'1+) todo-category-number))))
-  (todo-category-select)
-  (goto-char (point-min)))
+  (let ((setcatnum (lambda () (1+ (mod (- todo-category-number
+                                          (if back 2 0))
+                                      (length todo-categories))))))
+    (setq todo-category-number (funcall setcatnum))
+    (when todo-skip-archived-categories
+      (while (and (zerop (todo-get-count 'todo))
+                  (zerop (todo-get-count 'done))
+                  (not (zerop (todo-get-count 'archived))))
+        (setq todo-category-number (funcall setcatnum))))
+    (todo-category-select)
+    (goto-char (point-min))))
 
 (defun todo-backward-category ()
   "Visit the numerically previous category in this todo file.
@@ -933,6 +933,7 @@ Categories mode."
         (todo-category-number category)
         (todo-category-select)
         (goto-char (point-min))
+       (if (and (boundp 'hl-line-mode) hl-line-mode) (hl-line-highlight))
         (when add-item (todo-insert-item--basic))))))
 
 (defun todo-next-item (&optional count)
@@ -1860,15 +1861,18 @@ their associated keys and their effects."
          (region (eq where 'region))
          (here (eq where 'here))
          diary-item)
-      (when copy
-       (cond
-        ((not (eq major-mode 'todo-mode))
-         (user-error "You must be in Todo mode to copy a todo item"))
-        ((todo-done-item-p)
-         (user-error "You cannot copy a done item as a new todo item"))
-        ((looking-at "^$")
-         (user-error "Point must be on a todo item to copy it")))
-       (setq diary-item (todo-diary-item-p)))
+      (when (and arg here)
+        (user-error "Here insertion only valid in current category"))
+      (when (and (or copy here)
+                 (or (not (eq major-mode 'todo-mode)) (todo-done-item-p)
+                     (when copy (looking-at "^$"))
+                     (save-excursion
+                       (beginning-of-line)
+                       ;; Point is on done items separator.
+                       (looking-at todo-category-done))))
+        (user-error (concat "Item " (if copy "copying" "insertion")
+                            " is not valid here")))
+      (when copy (setq diary-item (todo-diary-item-p)))
       (when region
        (let (use-empty-active-region)
          (unless (and todo-use-only-highlighted-region (use-region-p))
@@ -1876,7 +1880,6 @@ their associated keys and their effects."
       (let* ((obuf (current-buffer))
             (ocat (todo-current-category))
             (opoint (point))
-            (todo-mm (eq major-mode 'todo-mode))
             (cat+file (cond ((equal arg '(4))
                              (todo-read-category "Insert in category: "))
                             ((equal arg '(16))
@@ -1894,7 +1897,10 @@ their associated keys and their effects."
             (new-item (cond (copy (todo-item-string))
                             (region (buffer-substring-no-properties
                                      (region-beginning) (region-end)))
-                            (t (read-from-minibuffer "Todo item: "))))
+                            (t (if (eq major-mode 'todo-archive-mode)
+                                    (user-error (concat "Cannot insert a new 
Todo"
+                                                        " item in an archive"))
+                                  (read-from-minibuffer "Todo item: ")))))
             (date-string (cond
                           ((eq date-type 'date)
                            (todo-read-date))
@@ -1931,7 +1937,6 @@ their associated keys and their effects."
        (unless todo-global-current-todo-file
          (setq todo-global-current-todo-file todo-current-todo-file))
        (let ((buffer-read-only nil)
-             (called-from-outside (not (and todo-mm (equal cat ocat))))
              done-only item-added)
          (unless copy
            (setq new-item
@@ -1955,14 +1960,8 @@ their associated keys and their effects."
                                                     "\n\t" new-item nil nil 
1)))
          (unwind-protect
              (progn
-               ;; Make sure the correct category is selected.  There
-               ;; are two cases: (i) we just visited the file, so no
-               ;; category is selected yet, or (ii) we invoked
-               ;; insertion "here" from outside the category we want
-               ;; to insert in (with priority insertion, category
-               ;; selection is done by todo-set-item-priority).
-               (when (or (= (- (point-max) (point-min)) (buffer-size))
-                         (and here called-from-outside))
+                ;; If we just visited the file, no category is selected yet.
+                (when (= (- (point-max) (point-min)) (buffer-size))
                  (todo-category-number cat)
                  (todo-category-select))
                ;; If only done items are displayed in category,
@@ -1973,16 +1972,7 @@ their associated keys and their effects."
                  (setq done-only t)
                  (todo-toggle-view-done-only))
                (if here
-                   (progn
-                     ;; If command was invoked with point in done
-                     ;; items section or outside of the current
-                     ;; category, can't insert "here", so to be
-                     ;; useful give new item top priority.
-                     (when (or (todo-done-item-section-p)
-                               called-from-outside
-                               done-only)
-                       (goto-char (point-min)))
-                     (todo-insert-with-overlays new-item))
+                    (todo-insert-with-overlays new-item)
                  (todo-set-item-priority new-item cat t))
                (setq item-added t))
            ;; If user cancels before setting priority, restore
@@ -2097,7 +2087,14 @@ the item at point."
              (setq todo-categories-with-marks
                    (assq-delete-all cat todo-categories-with-marks)))
            (todo-update-categories-sexp)
-           (todo-prefix-overlays)))
+           (todo-prefix-overlays)
+            (when (and (zerop (todo-get-count 'diary))
+                       (save-excursion
+                         (goto-char (point-min))
+                         (re-search-forward
+                          (concat "^" (regexp-quote todo-category-done))
+                         nil t)))
+              (let (todo-show-with-done) (todo-category-select)))))
       (if ov (delete-overlay ov)))))
 
 (defvar todo-edit-item--param-key-alist)
@@ -2340,7 +2337,7 @@ made in the number or names of categories."
                            ((or (string= omonth "*") (= mm 13))
                             (user-error "Cannot increment *"))
                            (t
-                            (let ((mminc (+ mm inc)))
+                            (let ((mminc (+ mm inc (if (< inc 0) 12 0))))
                               ;; Increment or decrement month by INC
                               ;; modulo 12.
                               (setq mm (% mminc 12))
@@ -2549,7 +2546,11 @@ whose value can be either of the symbols `raise' or 
`lower',
 meaning to raise or lower the item's priority by one."
   (interactive)
   (unless (and (or (called-interactively-p 'any) (memq arg '(raise lower)))
-              (or (todo-done-item-p) (looking-at "^$")))
+               ;; Noop if point is not on a todo (i.e. not done) item.
+              (or (todo-done-item-p) (looking-at "^$")
+                   ;; On done items separator.
+                   (save-excursion (beginning-of-line)
+                                   (looking-at todo-category-done))))
     (let* ((item (or item (todo-item-string)))
           (marked (todo-marked-item-p))
           (cat (or cat (cond ((eq major-mode 'todo-mode)
@@ -2697,9 +2698,13 @@ section in the category moved to."
   (interactive "P")
   (let* ((cat1 (todo-current-category))
         (marked (assoc cat1 todo-categories-with-marks)))
-    ;; Noop if point is not on an item and there are no marked items.
-    (unless (and (looking-at "^$")
-                (not marked))
+    (unless
+        ;; Noop if point is not on an item and there are no marked items.
+        (and (or (looking-at "^$")
+                 ;; On done items separator.
+                 (save-excursion (beginning-of-line)
+                                 (looking-at todo-category-done)))
+             (not marked))
       (let* ((buffer-read-only)
             (file1 todo-current-todo-file)
             (item (todo-item-string))
@@ -2856,10 +2861,14 @@ visible."
   (let* ((cat (todo-current-category))
         (marked (assoc cat todo-categories-with-marks)))
     (when marked (todo--user-error-if-marked-done-item))
-    (unless (and (not marked)
-                (or (todo-done-item-p)
-                    ;; Point is between todo and done items.
-                    (looking-at "^$")))
+    (unless
+        ;; Noop if point is not on a todo (i.e. not done) item and
+        ;; there are no marked items.
+        (and (or (todo-done-item-p) (looking-at "^$")
+                 ;; On done items separator.
+                 (save-excursion (beginning-of-line)
+                                 (looking-at todo-category-done)))
+             (not marked))
       (let* ((date-string (calendar-date-string (calendar-current-date) t t))
             (time-string (if todo-always-add-time-string
                              (concat " " (substring (current-time-string)
@@ -4032,15 +4041,16 @@ regexp items."
   "Choose a filtered items file and visit it."
   (interactive)
   (let ((files (directory-files todo-directory t "\\.tod[rty]$" t))
-       falist file)
+       falist sfnlist file)
     (dolist (f files)
-      (let ((type (cond ((equal (file-name-extension f) "todr") "regexp")
+      (let ((sf-name (todo-short-file-name f))
+            (type (cond ((equal (file-name-extension f) "todr") "regexp")
                        ((equal (file-name-extension f) "todt") "top")
                        ((equal (file-name-extension f) "tody") "diary"))))
-       (push (cons (concat (todo-short-file-name f) " (" type ")") f)
-             falist)))
+       (push (cons (concat sf-name " (" type ")") f) falist)))
+    (setq sfnlist (mapcar #'car falist))
     (setq file (completing-read "Choose a filtered items file: "
-                               falist nil t nil nil (car falist)))
+                               falist nil t nil 'sfnlist (caar falist)))
     (setq file (cdr (assoc-string file falist)))
     (find-file file)
     (unless (derived-mode-p 'todo-filtered-items-mode)
@@ -4050,25 +4060,26 @@ regexp items."
 (defun todo-go-to-source-item ()
   "Display the file and category of the filtered item at point."
   (interactive)
-  (let* ((str (todo-item-string))
-        (buf (current-buffer))
-        (res (todo-find-item str))
-        (found (nth 0 res))
-        (file (nth 1 res))
-        (cat (nth 2 res)))
-    (if (not found)
-       (message "Category %s does not contain this item." cat)
-      (kill-buffer buf)
-      (set-window-buffer (selected-window)
-                        (set-buffer (find-buffer-visiting file)))
-      (setq todo-current-todo-file file)
-      (setq todo-category-number (todo-category-number cat))
-      (let ((todo-show-with-done (if (or todo-filter-done-items
-                                         (eq (cdr found) 'done))
-                                     t
-                                   todo-show-with-done)))
-       (todo-category-select))
-      (goto-char (car found)))))
+  (unless (looking-at "^$")             ; Empty line at EOB.
+    (let* ((str (todo-item-string))
+           (buf (current-buffer))
+           (res (todo-find-item str))
+           (found (nth 0 res))
+           (file (nth 1 res))
+           (cat (nth 2 res)))
+      (if (not found)
+          (message "Category %s does not contain this item." cat)
+        (kill-buffer buf)
+        (set-window-buffer (selected-window)
+                           (set-buffer (find-buffer-visiting file)))
+        (setq todo-current-todo-file file)
+        (setq todo-category-number (todo-category-number cat))
+        (let ((todo-show-with-done (if (or todo-filter-done-items
+                                            (eq (cdr found) 'done))
+                                        t
+                                      todo-show-with-done)))
+          (todo-category-select))
+        (goto-char (car found))))))
 
 (defvar todo-multiple-filter-files nil
   "List of files selected from `todo-multiple-filter-files' widget.")
@@ -4520,8 +4531,11 @@ its priority has changed, and `same' otherwise."
 (defun todo-save-filtered-items-buffer ()
   "Save current Filtered Items buffer to a file.
 If the file already exists, overwrite it only on confirmation."
-  (let ((filename (or (buffer-file-name) (todo-filter-items-filename))))
-    (write-file filename t)))
+  (let ((filename (or (buffer-file-name) (todo-filter-items-filename)))
+        (bufname (buffer-name)))
+    (write-file filename t)
+    (setq buffer-read-only t)
+    (rename-buffer bufname)))
 
 ;; 
-----------------------------------------------------------------------------
 ;;; Printing Todo mode buffers
@@ -5132,6 +5146,8 @@ but the categories sexp differs from the current value of
                      (forward-line)
                      (looking-at (concat "^"
                                          (regexp-quote todo-category-done))))))
+           ;; Point is on done items separator.
+           (save-excursion (beginning-of-line) (looking-at todo-category-done))
           ;; Buffer is widened.
           (looking-at (regexp-quote todo-category-beg)))
     (goto-char (line-beginning-position))
@@ -5141,8 +5157,11 @@ but the categories sexp differs from the current value of
 
 (defun todo-item-end ()
   "Move to end of current todo item and return its position."
-  ;; Items cannot end with a blank line.
-  (unless (looking-at "^$")
+  (unless (or
+           ;; Items cannot end with a blank line.
+           (looking-at "^$")
+           ;; Point is on done items separator.
+           (save-excursion (beginning-of-line) (looking-at 
todo-category-done)))
     (let* ((done (todo-done-item-p))
           (to-lim nil)
           ;; For todo items, end is before the done items section, for done
@@ -6419,9 +6438,6 @@ Filtered Items mode following todo (not done) items."
     ("N"  todo-toggle-prefix-numbers)
     ("PB" todo-print-buffer)
     ("PF" todo-print-buffer-to-file)
-    ("b"  todo-backward-category)
-    ("d"  todo-item-done)
-    ("f"  todo-forward-category)
     ("j"  todo-jump-to-category)
     ("n"  todo-next-item)
     ("p"  todo-previous-item)
@@ -6436,6 +6452,8 @@ Filtered Items mode following todo (not done) items."
     ("Fc" todo-show-categories-table)
     ("S"  todo-search)
     ("X"  todo-clear-matches)
+    ("b"  todo-backward-category)
+    ("f"  todo-forward-category)
     ("*"  todo-toggle-mark-item)
    )
   "List of key bindings for Todo and Todo Archive modes.")
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 925a7d5..21ee50c 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1989,6 +1989,19 @@ Optional arg HOW-TO determines how to treat the target.
       dired-dirs)))
 
 
+
+;; We use this function in `dired-create-directory' and
+;; `dired-create-empty-file'; the return value is the new entry
+;; in the updated Dired buffer.
+(defun dired--find-topmost-parent-dir (filename)
+  "Return the topmost nonexistent parent dir of FILENAME.
+FILENAME is a full file name."
+  (let ((try filename) new)
+    (while (and try (not (file-exists-p try)) (not (equal new try)))
+      (setq new try
+           try (directory-file-name (file-name-directory try))))
+    new))
+
 ;;;###autoload
 (defun dired-create-directory (directory)
   "Create a directory called DIRECTORY.
@@ -1997,18 +2010,32 @@ If DIRECTORY already exists, signal an error."
   (interactive
    (list (read-file-name "Create directory: " (dired-current-directory))))
   (let* ((expanded (directory-file-name (expand-file-name directory)))
-        (try expanded) new)
+        new)
     (if (file-exists-p expanded)
        (error "Cannot create directory %s: file exists" expanded))
-    ;; Find the topmost nonexistent parent dir (variable `new')
-    (while (and try (not (file-exists-p try)) (not (equal new try)))
-      (setq new try
-           try (directory-file-name (file-name-directory try))))
+    (setq new (dired--find-topmost-parent-dir expanded))
     (make-directory expanded t)
     (when new
       (dired-add-file new)
       (dired-move-to-filename))))
 
+;;;###autoload
+(defun dired-create-empty-file (file)
+  "Create an empty file called FILE.
+ Add a new entry for the new file in the Dired buffer.
+ Parent directories of FILE are created as needed.
+ If FILE already exists, signal an error."
+  (interactive (list (read-file-name "Create empty file: ")))
+  (let* ((expanded (expand-file-name file))
+         new)
+    (if (file-exists-p expanded)
+        (error "Cannot create file %s: file exists" expanded))
+    (setq new (dired--find-topmost-parent-dir expanded))
+    (make-empty-file file 'parents)
+    (when new
+      (dired-add-file new)
+      (dired-move-to-filename))))
+
 (defun dired-into-dir-with-symlinks (target)
   (and (file-directory-p target)
        (not (file-symlink-p target))))
diff --git a/lisp/dired.el b/lisp/dired.el
index 1348df6..26a7449 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1802,6 +1802,9 @@ Do so according to the former subdir alist 
OLD-SUBDIR-ALIST."
     (define-key map [menu-bar immediate create-directory]
       '(menu-item "Create Directory..." dired-create-directory
                  :help "Create a directory"))
+    (define-key map [menu-bar immediate create-empty-file]
+      '(menu-item "Create Empty file..." dired-create-empty-file
+                 :help "Create an empty file"))
     (define-key map [menu-bar immediate wdired-mode]
       '(menu-item "Edit File Names" wdired-change-to-wdired-mode
                  :help "Put a Dired buffer in a mode in which filenames are 
editable"
diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
new file mode 100644
index 0000000..f13b43b
--- /dev/null
+++ b/lisp/emacs-lisp/backtrace.el
@@ -0,0 +1,916 @@
+;;; backtrace.el --- generic major mode for Elisp backtraces -*- 
lexical-binding: t -*-
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Gemini Lasswell
+;; Keywords: lisp, tools, maint
+;; Version: 1.0
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file defines Backtrace mode, a generic major mode for displaying
+;; Elisp stack backtraces, which can be used as is or inherited from
+;; by another mode.
+
+;; For usage information, see the documentation of `backtrace-mode'.
+
+;;; Code:
+
+(eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'pcase))
+(eval-when-compile (require 'subr-x))        ; if-let
+(require 'help-mode)     ; Define `help-function-def' button type.
+(require 'lisp-mode)
+
+;;; Options
+
+(defgroup backtrace nil
+  "Viewing of Elisp backtraces."
+  :group 'lisp)
+
+(defcustom backtrace-fontify t
+  "If non-nil, fontify Backtrace buffers.
+Set to nil to disable fontification, which may be necessary in
+order to debug the code that does fontification."
+  :type 'boolean
+  :group 'backtrace
+  :version "27.1")
+
+(defcustom backtrace-line-length 5000
+  "Target length for lines in Backtrace buffers.
+Backtrace mode will attempt to abbreviate printing of backtrace
+frames to make them shorter than this, but success is not
+guaranteed.  If set to nil or zero, Backtrace mode will not
+abbreviate the forms it prints."
+  :type 'integer
+  :group 'backtrace
+  :version "27.1")
+
+;;; Backtrace frame data structure
+
+(cl-defstruct
+    (backtrace-frame
+     (:constructor backtrace-make-frame))
+  evald  ; Non-nil if argument evaluation is complete.
+  fun    ; The function called/to call in this frame.
+  args   ; Either evaluated or unevaluated arguments to the function.
+  flags  ; A plist, possible properties are :debug-on-exit and 
:source-available.
+  locals ; An alist containing variable names and values.
+  buffer ; If non-nil, the buffer in use by eval-buffer or eval-region.
+  pos    ; The position in the buffer.
+  )
+
+(cl-defun backtrace-get-frames
+    (&optional base &key (constructor #'backtrace-make-frame))
+  "Collect all frames of current backtrace into a list.
+The list will contain objects made by CONSTRUCTOR, which
+defaults to `backtrace-make-frame' and which, if provided, should
+be the constructor of a structure which includes
+`backtrace-frame'.  If non-nil, BASE should be a function, and
+frames before its nearest activation frame are discarded."
+  (let ((frames nil)
+        (eval-buffers eval-buffer-list))
+    (mapbacktrace (lambda (evald fun args flags)
+                    (push (funcall constructor
+                                   :evald evald :fun fun
+                                   :args args :flags flags)
+                          frames))
+                  (or base 'backtrace-get-frames))
+    (setq frames (nreverse frames))
+    ;; Add local variables to each frame, and the buffer position
+    ;; to frames containing eval-buffer or eval-region.
+    (dotimes (idx (length frames))
+      (let ((frame (nth idx frames)))
+        ;; `backtrace--locals' gives an error when idx is 0.  But the
+        ;; locals for frame 0 are not needed, because when we get here
+        ;; from debug-on-entry, the locals aren't bound yet, and when
+        ;; coming from Edebug or ERT there is an Edebug or ERT
+        ;; function at frame 0.
+        (when (> idx 0)
+          (setf (backtrace-frame-locals frame)
+                (backtrace--locals idx (or base 'backtrace-get-frames))))
+        (when (and eval-buffers (memq (backtrace-frame-fun frame)
+                                      '(eval-buffer eval-region)))
+          ;; This will get the wrong result if there are two nested
+          ;; eval-region calls for the same buffer.  That's not a very
+          ;; useful case.
+          (with-current-buffer (pop eval-buffers)
+            (setf (backtrace-frame-buffer frame) (current-buffer))
+            (setf (backtrace-frame-pos frame) (point))))))
+    frames))
+
+;; Button definition for jumping to a buffer position.
+
+(define-button-type 'backtrace-buffer-pos
+  'action #'backtrace--pop-to-buffer-pos
+  'help-echo "mouse-2, RET: Show reading position")
+
+(defun backtrace--pop-to-buffer-pos (button)
+  "Pop to the buffer and position for the BUTTON at point."
+  (let* ((buffer (button-get button 'backtrace-buffer))
+         (pos (button-get button 'backtrace-pos)))
+    (if (buffer-live-p buffer)
+        (progn
+          (pop-to-buffer buffer)
+          (goto-char (max (point-min) (min (point-max) pos))))
+      (message "Buffer has been killed"))))
+
+;; Font Locking support
+
+(defconst backtrace--font-lock-keywords
+  '((backtrace--match-ellipsis-in-string
+     (1 'button prepend)))
+  "Expressions to fontify in Backtrace mode.
+Fontify these in addition to the expressions Emacs Lisp mode
+fontifies.")
+
+(defconst backtrace-font-lock-keywords
+  (append lisp-el-font-lock-keywords-for-backtraces
+          backtrace--font-lock-keywords)
+  "Default expressions to highlight in Backtrace mode.")
+(defconst backtrace-font-lock-keywords-1
+  (append lisp-el-font-lock-keywords-for-backtraces-1
+          backtrace--font-lock-keywords)
+  "Subdued level highlighting for Backtrace mode.")
+(defconst backtrace-font-lock-keywords-2
+  (append lisp-el-font-lock-keywords-for-backtraces-2
+          backtrace--font-lock-keywords)
+  "Gaudy level highlighting for Backtrace mode.")
+
+(defun backtrace--match-ellipsis-in-string (bound)
+  ;; Fontify ellipses within strings as buttons.
+  ;; This is necessary because ellipses are text property buttons
+  ;; instead of overlay buttons, which is done because there could
+  ;; be a large number of them.
+  (when (re-search-forward "\\(\\.\\.\\.\\)\"" bound t)
+    (and (get-text-property (- (point) 2) 'cl-print-ellipsis)
+         (get-text-property (- (point) 3) 'cl-print-ellipsis)
+         (get-text-property (- (point) 4) 'cl-print-ellipsis))))
+
+;;; Xref support
+
+(defun backtrace--xref-backend () 'elisp)
+
+;;; Backtrace mode variables
+
+(defvar-local backtrace-frames nil
+  "Stack frames displayed in the current Backtrace buffer.
+This should be a list of `backtrace-frame' objects.")
+
+(defvar-local backtrace-view nil
+  "A plist describing how to render backtrace frames.
+Possible entries are :show-flags, :show-locals and :print-circle.")
+
+(defvar-local backtrace-insert-header-function nil
+  "Function for inserting a header for the current Backtrace buffer.
+If nil, no header will be created.  Note that Backtrace buffers
+are fontified as in Emacs Lisp Mode, the header text included.")
+
+(defvar backtrace-revert-hook nil
+  "Hook run before reverting a Backtrace buffer.
+This is commonly used to recompute `backtrace-frames'.")
+
+(defvar-local backtrace-print-function #'cl-prin1
+  "Function used to print values in the current Backtrace buffer.")
+
+(defvar-local backtrace-goto-source-functions nil
+  "Abnormal hook used to jump to the source code for the current frame.
+Each hook function is called with no argument, and should return
+non-nil if it is able to switch to the buffer containing the
+source code.  Execution of the hook will stop if one of the
+functions returns non-nil.  When adding a function to this hook,
+you should also set the :source-available flag for the backtrace
+frames where the source code location is known.")
+
+(defvar backtrace-mode-map
+  (let ((map (copy-keymap special-mode-map)))
+    (set-keymap-parent map button-buffer-map)
+    (define-key map "n" 'backtrace-forward-frame)
+    (define-key map "p" 'backtrace-backward-frame)
+    (define-key map "v" 'backtrace-toggle-locals)
+    (define-key map "#" 'backtrace-toggle-print-circle)
+    (define-key map "s" 'backtrace-goto-source)
+    (define-key map "\C-m" 'backtrace-help-follow-symbol)
+    (define-key map "+" 'backtrace-multi-line)
+    (define-key map "-" 'backtrace-single-line)
+    (define-key map "." 'backtrace-expand-ellipses)
+    (define-key map [follow-link] 'mouse-face)
+    (define-key map [mouse-2] 'mouse-select-window)
+    (easy-menu-define nil map ""
+      '("Backtrace"
+        ["Next Frame" backtrace-forward-frame
+         :help "Move cursor forwards to the start of a backtrace frame"]
+        ["Previous Frame" backtrace-backward-frame
+         :help "Move cursor backwards to the start of a backtrace frame"]
+        "--"
+        ["Show Variables" backtrace-toggle-locals
+         :style toggle
+         :active (backtrace-get-index)
+         :selected (plist-get (backtrace-get-view) :show-locals)
+         :help "Show or hide the local variables for the frame at point"]
+        ["Expand \"...\"s" backtrace-expand-ellipses
+         :help "Expand all the abbreviated forms in the current frame"]
+        ["Show on Multiple Lines" backtrace-multi-line
+         :help "Use line breaks and indentation to make a form more readable"]
+        ["Show on Single Line" backtrace-single-line]
+        "--"
+        ["Go to Source" backtrace-goto-source
+         :active (and (backtrace-get-index)
+                      (plist-get (backtrace-frame-flags
+                                  (nth (backtrace-get-index) backtrace-frames))
+                                 :source-available))
+         :help "Show the source code for the current frame"]
+        ["Help for Symbol" backtrace-help-follow-symbol
+         :help "Show help for symbol at point"]
+        ["Describe Backtrace Mode" describe-mode
+         :help "Display documentation for backtrace-mode"]))
+    map)
+  "Local keymap for `backtrace-mode' buffers.")
+
+(defconst backtrace--flags-width 2
+  "Width in characters of the flags for a backtrace frame.")
+
+;;; Navigation and Text Properties
+
+;; This mode uses the following text properties:
+;; backtrace-index: The index into the buffer-local variable
+;;   `backtrace-frames' for the frame at point, or nil if outside of a
+;;   frame (in the buffer header).
+;; backtrace-view: A plist describing how the frame is printed.  See
+;;   the docstring for the buffer-local variable `backtrace-view.
+;; backtrace-section: The part of a frame which point is in.  Either
+;;   `func' or `locals'.  At the moment just used to show and hide the
+;;   local variables.  Derived modes which do additional printing
+;;   could define their own frame sections.
+;; backtrace-form: A value applied to each printed representation of a
+;;   top-level s-expression, which needs to be different for sexps
+;;   printed adjacent to each other, so the limits can be quickly
+;;   found for pretty-printing.
+
+(defsubst backtrace-get-index (&optional pos)
+  "Return the index of the backtrace frame at POS.
+The value is an index into `backtrace-frames', or nil.
+POS, if omitted or nil, defaults to point."
+  (get-text-property (or pos (point)) 'backtrace-index))
+
+(defsubst backtrace-get-section (&optional pos)
+  "Return the section of a backtrace frame at POS.
+POS, if omitted or nil, defaults to point."
+  (get-text-property (or pos (point)) 'backtrace-section))
+
+(defsubst backtrace-get-view (&optional pos)
+  "Return the view plist of the backtrace frame at POS.
+POS, if omitted or nil, defaults to point."
+  (get-text-property (or pos (point)) 'backtrace-view))
+
+(defsubst backtrace-get-form (&optional pos)
+  "Return the backtrace form data for the form printed at POS.
+POS, if omitted or nil, defaults to point."
+  (get-text-property (or pos (point)) 'backtrace-form))
+
+(defun backtrace-get-frame-start (&optional pos)
+  "Return the beginning position of the frame at POS in the buffer.
+POS, if omitted or nil, defaults to point."
+  (let ((posn (or pos (point))))
+    (if (or (= (point-min) posn)
+            (not (eq (backtrace-get-index posn)
+                     (backtrace-get-index (1- posn)))))
+        posn
+      (previous-single-property-change posn 'backtrace-index nil 
(point-min)))))
+
+(defun backtrace-get-frame-end (&optional pos)
+  "Return the position of the end of the frame at POS in the buffer.
+POS, if omitted or nil, defaults to point."
+  (next-single-property-change (or pos (point))
+                                    'backtrace-index nil (point-max)))
+
+(defun backtrace-forward-frame ()
+  "Move forward to the beginning of the next frame."
+  (interactive)
+  (let ((max (backtrace-get-frame-end)))
+    (when (= max (point-max))
+      (user-error "No next stack frame"))
+    (goto-char max)))
+
+(defun backtrace-backward-frame ()
+  "Move backward to the start of a stack frame."
+  (interactive)
+  (let ((current-index (backtrace-get-index))
+        (min (backtrace-get-frame-start)))
+    (if (or (and (/= (point) (point-max)) (null current-index))
+            (= min (point-min))
+            (and (= min (point))
+                 (null (backtrace-get-index (1- min)))))
+        (user-error "No previous stack frame"))
+    (if (= min (point))
+        (goto-char (backtrace-get-frame-start (1- min)))
+      (goto-char min))))
+
+;; Other Backtrace mode commands
+
+(defun backtrace-revert (&rest _ignored)
+  "The `revert-buffer-function' for `backtrace-mode'.
+It runs `backtrace-revert-hook', then calls `backtrace-print'."
+  (interactive)
+  (unless (derived-mode-p 'backtrace-mode)
+    (error "The current buffer is not in Backtrace mode"))
+  (run-hooks 'backtrace-revert-hook)
+  (backtrace-print t))
+
+(defmacro backtrace--with-output-variables (view &rest body)
+  "Bind output variables according to VIEW and execute BODY."
+  (declare (indent 1))
+  `(let ((print-escape-control-characters t)
+         (print-escape-newlines t)
+         (print-circle (plist-get ,view :print-circle))
+         (standard-output (current-buffer)))
+     ,@body))
+
+(defun backtrace-toggle-locals (&optional all)
+  "Toggle the display of local variables for the backtrace frame at point.
+With prefix argument ALL, toggle the value of :show-locals in
+`backtrace-view', which affects all of the backtrace frames in
+the buffer."
+  (interactive "P")
+  (if all
+      (let ((pos (make-marker))
+            (visible (not (plist-get backtrace-view :show-locals))))
+        (setq backtrace-view (plist-put backtrace-view :show-locals visible))
+        (set-marker-insertion-type pos t)
+        (set-marker pos (point))
+        (goto-char (point-min))
+        ;; Skip the header.
+        (unless (backtrace-get-index)
+          (goto-char (backtrace-get-frame-end)))
+        (while (< (point) (point-max))
+          (backtrace--set-frame-locals-visible visible)
+          (goto-char (backtrace-get-frame-end)))
+        (goto-char pos)
+        (when (invisible-p pos)
+          (goto-char (backtrace-get-frame-start))))
+    (let ((index (backtrace-get-index)))
+      (unless index
+        (user-error "Not in a stack frame"))
+      (backtrace--set-frame-locals-visible
+       (not (plist-get (backtrace-get-view) :show-locals))))))
+
+(defun backtrace--set-frame-locals-visible (visible)
+  "Set the visibility of the local vars for the frame at point to VISIBLE."
+  (let ((pos (point))
+        (index (backtrace-get-index))
+        (start (backtrace-get-frame-start))
+        (end (backtrace-get-frame-end))
+        (view (copy-sequence (backtrace-get-view)))
+        (inhibit-read-only t))
+    (setq view (plist-put view :show-locals visible))
+    (goto-char (backtrace-get-frame-start))
+    (while (not (or (= (point) end)
+                    (eq (backtrace-get-section) 'locals)))
+      (goto-char (next-single-property-change (point)
+                                              'backtrace-section nil end)))
+    (cond
+     ((and (= (point) end) visible)
+      ;; The locals section doesn't exist so create it.
+      (let ((standard-output (current-buffer)))
+        (backtrace--with-output-variables view
+          (backtrace--print-locals
+           (nth index backtrace-frames) view))
+        (add-text-properties end (point) `(backtrace-index ,index))
+        (goto-char pos)))
+     ((/= (point) end)
+      ;; The locals section does exist, so add or remove the overlay.
+      (backtrace--set-locals-visible-overlay (point) end visible)
+      (goto-char (if (invisible-p pos) start pos))))
+    (add-text-properties start (backtrace-get-frame-end)
+                         `(backtrace-view ,view))))
+
+(defun backtrace--set-locals-visible-overlay (beg end visible)
+  (backtrace--change-button-skip beg end (not visible))
+  (if visible
+      (remove-overlays beg end 'invisible t)
+    (let ((o (make-overlay beg end)))
+      (overlay-put o 'invisible t)
+      (overlay-put o 'evaporate t))))
+
+(defun backtrace--change-button-skip (beg end value)
+  "Change the skip property on all buttons between BEG and END.
+Set it to VALUE unless the button is a `backtrace-ellipsis' button."
+  (let ((inhibit-read-only t))
+    (setq beg (next-button beg))
+    (while (and beg (< beg end))
+      (unless (eq (button-type beg) 'backtrace-ellipsis)
+          (button-put beg 'skip value))
+      (setq beg (next-button beg)))))
+
+(defun backtrace-toggle-print-circle (&optional all)
+  "Toggle `print-circle' for the backtrace frame at point.
+With prefix argument ALL, toggle the value of :print-circle in
+`backtrace-view', which affects all of the backtrace frames in
+the buffer."
+  (interactive "P")
+  (backtrace--toggle-feature :print-circle all))
+
+(defun backtrace--toggle-feature (feature all)
+  "Toggle FEATURE for the current backtrace frame or for the buffer.
+FEATURE should be one of the options in `backtrace-view'.  If ALL
+is non-nil, toggle FEATURE for all frames in the buffer.  After
+toggling the feature, reprint the affected frame(s).  Afterwards
+position point at the start of the frame it was in before."
+  (if all
+      (let ((index (backtrace-get-index))
+            (pos (point))
+            (at-end (= (point) (point-max)))
+            (value (not (plist-get backtrace-view feature))))
+        (setq backtrace-view (plist-put backtrace-view feature value))
+        (goto-char (point-min))
+        ;; Skip the header.
+        (unless (backtrace-get-index)
+          (goto-char (backtrace-get-frame-end)))
+        (while (< (point) (point-max))
+          (backtrace--set-feature feature value)
+          (goto-char (backtrace-get-frame-end)))
+        (if (not index)
+            (goto-char (if at-end (point-max) pos))
+          (goto-char (point-min))
+          (while (and (not (eql index (backtrace-get-index)))
+                      (< (point) (point-max)))
+            (goto-char (backtrace-get-frame-end)))))
+    (let ((index (backtrace-get-index)))
+      (unless index
+        (user-error "Not in a stack frame"))
+      (backtrace--set-feature feature
+                              (not (plist-get (backtrace-get-view) 
feature))))))
+
+(defun backtrace--set-feature (feature value)
+  "Set FEATURE in the view plist of the frame at point to VALUE.
+Reprint the frame with the new view plist."
+  (let ((inhibit-read-only t)
+        (view (copy-sequence (backtrace-get-view)))
+        (index (backtrace-get-index))
+        (min (backtrace-get-frame-start))
+        (max (backtrace-get-frame-end)))
+    (setq view (plist-put view feature value))
+    (delete-region min max)
+    (goto-char min)
+    (backtrace-print-frame (nth index backtrace-frames) view)
+    (add-text-properties min (point)
+                         `(backtrace-index ,index backtrace-view ,view))
+    (goto-char min)))
+
+(defun backtrace-expand-ellipsis (button)
+  "Expand display of the elided form at BUTTON."
+  (interactive)
+  (goto-char (button-start button))
+  (unless (get-text-property (point) 'cl-print-ellipsis)
+    (if (and (> (point) (point-min))
+             (get-text-property (1- (point)) 'cl-print-ellipsis))
+        (backward-char)
+      (user-error "No ellipsis to expand here")))
+  (let* ((end (next-single-property-change (point) 'cl-print-ellipsis))
+         (begin (previous-single-property-change end 'cl-print-ellipsis))
+         (value (get-text-property begin 'cl-print-ellipsis))
+         (props (backtrace-get-text-properties begin))
+         (inhibit-read-only t))
+    (backtrace--with-output-variables (backtrace-get-view)
+      (delete-region begin end)
+      (insert (cl-print-to-string-with-limit #'cl-print-expand-ellipsis value
+                                          backtrace-line-length))
+      (setq end (point))
+      (goto-char begin)
+      (while (< (point) end)
+        (let ((next (next-single-property-change (point) 'cl-print-ellipsis
+                                                 nil end)))
+          (when (get-text-property (point) 'cl-print-ellipsis)
+            (make-text-button (point) next :type 'backtrace-ellipsis))
+          (goto-char next)))
+      (goto-char begin)
+      (add-text-properties begin end props))))
+
+(defun backtrace-expand-ellipses (&optional no-limit)
+  "Expand display of all \"...\"s in the backtrace frame at point.
+\\<backtrace-mode-map>
+Each ellipsis will be limited to `backtrace-line-length'
+characters in its expansion.  With optional prefix argument
+NO-LIMIT, do not limit the number of characters.  Note that with
+or without the argument, using this command can result in very
+long lines and very poor display performance.  If this happens
+and is a problem, use `\\[revert-buffer]' to return to the
+initial state of the Backtrace buffer."
+  (interactive "P")
+  (save-excursion
+    (let ((start (backtrace-get-frame-start))
+          (end (backtrace-get-frame-end))
+          (backtrace-line-length (unless no-limit backtrace-line-length)))
+      (goto-char end)
+      (while (> (point) start)
+        (let ((next (previous-single-property-change (point) 'cl-print-ellipsis
+                                                     nil start)))
+          (when (get-text-property (point) 'cl-print-ellipsis)
+            (push-button (point)))
+          (goto-char next))))))
+
+(defun backtrace-multi-line ()
+  "Show the top level s-expression at point on multiple lines with 
indentation."
+  (interactive)
+  (backtrace--reformat-sexp #'backtrace--multi-line))
+
+(defun backtrace--multi-line ()
+  "Pretty print the current buffer, then remove the trailing newline."
+  (set-syntax-table emacs-lisp-mode-syntax-table)
+  (pp-buffer)
+  (goto-char (1- (point-max)))
+  (delete-char 1))
+
+(defun backtrace-single-line ()
+  "Show the top level s-expression at point on one line."
+  (interactive)
+  (backtrace--reformat-sexp #'backtrace--single-line))
+
+(defun backtrace--single-line ()
+  "Replace line breaks and following indentation with spaces.
+Works on the current buffer."
+  (goto-char (point-min))
+  (while (re-search-forward "\n[[:blank:]]*" nil t)
+    (replace-match " ")))
+
+(defun backtrace--reformat-sexp (format-function)
+  "Reformat the top level sexp at point.
+Locate the top level sexp at or following point on the same line,
+and reformat it with FORMAT-FUNCTION, preserving the location of
+point within the sexp.  If no sexp is found before the end of
+the line or buffer, signal an error.
+
+FORMAT-FUNCTION will be called without arguments, with the
+current buffer set to a temporary buffer containing only the
+content of the sexp."
+  (let* ((orig-pos (point))
+         (pos (point))
+         (tag (backtrace-get-form pos))
+         (end (next-single-property-change pos 'backtrace-form))
+         (begin (previous-single-property-change end 'backtrace-form
+                                                 nil (point-min))))
+    (unless tag
+      (when (or (= end (point-max)) (> end (point-at-eol)))
+        (user-error "No form here to reformat"))
+      (goto-char end)
+      (setq pos end
+            end (next-single-property-change pos 'backtrace-form)
+            begin (previous-single-property-change end 'backtrace-form
+                                                   nil (point-min))))
+    (let* ((offset (when (>= orig-pos begin) (- orig-pos begin)))
+           (offset-marker (when offset (make-marker)))
+           (content (buffer-substring begin end))
+           (props (backtrace-get-text-properties begin))
+           (inhibit-read-only t))
+      (delete-region begin end)
+      (insert (with-temp-buffer
+                (insert content)
+                (when offset
+                  (set-marker-insertion-type offset-marker t)
+                  (set-marker offset-marker (+ (point-min) offset)))
+                (funcall format-function)
+                (when offset
+                  (setq offset (- (marker-position offset-marker) 
(point-min))))
+                (buffer-string)))
+      (when offset
+        (set-marker offset-marker (+ begin offset)))
+      (save-excursion
+        (goto-char begin)
+        (indent-sexp))
+      (add-text-properties begin (point) props)
+      (if offset
+          (goto-char (marker-position offset-marker))
+        (goto-char orig-pos)))))
+
+(defun backtrace-get-text-properties (pos)
+  "Return a plist of backtrace-mode's text properties at POS."
+  (apply #'append
+         (mapcar (lambda (prop)
+                   (list prop (get-text-property pos prop)))
+                 '(backtrace-section backtrace-index backtrace-view
+                                     backtrace-form))))
+
+(defun backtrace-goto-source ()
+  "If its location is known, jump to the source code for the frame at point."
+  (interactive)
+  (let* ((index (or (backtrace-get-index) (user-error "Not in a stack frame")))
+         (frame (nth index backtrace-frames))
+         (source-available (plist-get (backtrace-frame-flags frame)
+                                      :source-available)))
+    (unless (and source-available
+                 (catch 'done
+                   (dolist (func backtrace-goto-source-functions)
+                     (when (funcall func)
+                       (throw 'done t)))))
+      (user-error "Source code location not known"))))
+
+(defun backtrace-help-follow-symbol (&optional pos)
+  "Follow cross-reference at POS, defaulting to point.
+For the cross-reference format, see `help-make-xrefs'."
+  (interactive "d")
+  (unless pos
+    (setq pos (point)))
+  (unless (push-button pos)
+    ;; Check if the symbol under point is a function or variable.
+    (let ((sym
+          (intern
+           (save-excursion
+             (goto-char pos) (skip-syntax-backward "w_")
+             (buffer-substring (point)
+                               (progn (skip-syntax-forward "w_")
+                                      (point)))))))
+      (when (or (boundp sym) (fboundp sym) (facep sym))
+        (describe-symbol sym)))))
+
+;; Print backtrace frames
+
+(defun backtrace-print (&optional remember-pos)
+  "Populate the current Backtrace mode buffer.
+This erases the buffer and inserts printed representations of the
+frames.  Optional argument REMEMBER-POS, if non-nil, means to
+move point to the entry with the same ID element as the current
+line and recenter window line accordingly."
+  (let ((inhibit-read-only t)
+       entry-index saved-pt window-line)
+    (and remember-pos
+        (setq entry-index (backtrace-get-index))
+         (when (eq (window-buffer) (current-buffer))
+           (setq window-line
+                 (count-screen-lines (window-start) (point)))))
+    (erase-buffer)
+    (when backtrace-insert-header-function
+      (funcall backtrace-insert-header-function))
+    (dotimes (idx (length backtrace-frames))
+      (let ((beg (point))
+            (elt (nth idx backtrace-frames)))
+        (and entry-index
+             (equal entry-index idx)
+             (setq entry-index nil
+                   saved-pt (point)))
+        (backtrace-print-frame elt backtrace-view)
+        (add-text-properties
+         beg (point)
+         `(backtrace-index ,idx backtrace-view ,backtrace-view))))
+    (set-buffer-modified-p nil)
+    ;; If REMEMBER-POS was specified, move to the "old" location.
+    (if saved-pt
+       (progn (goto-char saved-pt)
+              (when window-line
+                 (recenter window-line)))
+      (goto-char (point-min)))))
+
+;; Define button type used for ...'s.
+;; Set skip property so you don't have to TAB through 100 of them to
+;; get to the next function name.
+(define-button-type 'backtrace-ellipsis
+  'skip t 'action #'backtrace-expand-ellipsis
+  'help-echo "mouse-2, RET: expand this ellipsis")
+
+(defun backtrace-print-to-string (obj &optional limit)
+  "Return a printed representation of OBJ formatted for backtraces.
+Attempt to get the length of the returned string under LIMIT
+charcters with appropriate settings of `print-level' and
+`print-length.'  LIMIT defaults to `backtrace-line-length'."
+  (backtrace--with-output-variables backtrace-view
+    (backtrace--print-to-string obj limit)))
+
+(defun backtrace--print-to-string (sexp &optional limit)
+  ;; This is for use by callers who wrap the call with
+  ;; backtrace--with-output-variables.
+  (setq limit (or limit backtrace-line-length))
+  (with-temp-buffer
+    (insert (cl-print-to-string-with-limit #'backtrace--print sexp limit))
+    ;; Add a unique backtrace-form property.
+    (put-text-property (point-min) (point) 'backtrace-form (gensym))
+    ;; Make buttons from all the "..."s.  Since there might be many of
+    ;; them, use text property buttons.
+    (goto-char (point-min))
+    (while (< (point) (point-max))
+      (let ((end (next-single-property-change (point) 'cl-print-ellipsis
+                                              nil (point-max))))
+        (when (get-text-property (point) 'cl-print-ellipsis)
+          (make-text-button (point) end :type 'backtrace-ellipsis))
+        (goto-char end)))
+    (buffer-string)))
+
+(defun backtrace-print-frame (frame view)
+  "Insert a backtrace FRAME at point formatted according to VIEW.
+Tag the sections of the frame with the `backtrace-section' text
+property for use by navigation."
+  (backtrace--with-output-variables view
+   (backtrace--print-flags frame view)
+   (backtrace--print-func-and-args frame view)
+   (backtrace--print-locals frame view)))
+
+(defun backtrace--print-flags (frame view)
+  "Print the flags of a backtrace FRAME if enabled in VIEW."
+  (let ((beg (point))
+        (flag (plist-get (backtrace-frame-flags frame) :debug-on-exit))
+        (source (plist-get (backtrace-frame-flags frame) :source-available)))
+    (when (plist-get view :show-flags)
+      (when source (insert ">"))
+      (when flag (insert "*")))
+    (insert (make-string (- backtrace--flags-width (- (point) beg)) ?\s))
+    (put-text-property beg (point) 'backtrace-section 'func)))
+
+(defun backtrace--print-func-and-args (frame _view)
+  "Print the function, arguments and buffer position of a backtrace FRAME.
+Format it according to VIEW."
+  (let* ((beg (point))
+         (evald (backtrace-frame-evald frame))
+         (fun   (backtrace-frame-fun frame))
+         (args  (backtrace-frame-args frame))
+         (def   (and (symbolp fun) (fboundp fun) (symbol-function fun)))
+         (fun-file (or (symbol-file fun 'defun)
+                            (and (subrp def)
+                                 (not (eq 'unevalled (cdr (subr-arity def))))
+                                 (find-lisp-object-file-name fun def))))
+         (fun-pt (point)))
+    (cond
+     ((and evald (not debugger-stack-frame-as-list))
+      (if (atom fun)
+          (funcall backtrace-print-function fun)
+        (insert
+         (backtrace--print-to-string fun (when args (/ backtrace-line-length 
2)))))
+      (if args
+          (insert (backtrace--print-to-string
+                   args (max (truncate (/ backtrace-line-length 5))
+                             (- backtrace-line-length (- (point) beg)))))
+        ;; The backtrace-form property is so that backtrace-multi-line
+        ;; will find it.  backtrace-multi-line doesn't do anything
+        ;; useful with it, just being consistent.
+        (let ((start (point)))
+          (insert "()")
+          (put-text-property start (point) 'backtrace-form t))))
+     (t
+      (let ((fun-and-args (cons fun args)))
+        (insert (backtrace--print-to-string fun-and-args)))
+      (cl-incf fun-pt)))
+    (when fun-file
+      (make-text-button fun-pt (+ fun-pt (length (symbol-name fun)))
+                        :type 'help-function-def
+                        'help-args (list fun fun-file)))
+    ;; After any frame that uses eval-buffer, insert a comment that
+    ;; states the buffer position it's reading at.
+    (when (backtrace-frame-pos frame)
+      (insert "  ; Reading at ")
+      (let ((pos (point)))
+        (insert (format "buffer position %d" (backtrace-frame-pos frame)))
+        (make-button pos (point) :type 'backtrace-buffer-pos
+                     'backtrace-buffer (backtrace-frame-buffer frame)
+                     'backtrace-pos (backtrace-frame-pos frame))))
+    (insert "\n")
+    (put-text-property beg (point) 'backtrace-section 'func)))
+
+(defun backtrace--print-locals (frame view)
+  "Print a backtrace FRAME's local variables according to VIEW.
+Print them only if :show-locals is non-nil in the VIEW plist."
+  (when (plist-get view :show-locals)
+    (let* ((beg (point))
+           (locals (backtrace-frame-locals frame)))
+      (if (null locals)
+         (insert "    [no locals]\n")
+        (pcase-dolist (`(,symbol . ,value) locals)
+          (insert "    ")
+          (backtrace--print symbol)
+         (insert " = ")
+          (insert (backtrace--print-to-string value))
+          (insert "\n")))
+      (put-text-property beg (point) 'backtrace-section 'locals))))
+
+(defun backtrace--print (obj &optional stream)
+  "Attempt to print OBJ to STREAM using `backtrace-print-function'.
+Fall back to `prin1' if there is an error."
+  (condition-case err
+      (funcall backtrace-print-function obj stream)
+    (error
+     (message "Error in backtrace printer: %S" err)
+     (prin1 obj stream))))
+
+(defun backtrace-update-flags ()
+  "Update the display of the flags in the backtrace frame at point."
+  (let ((view (backtrace-get-view))
+        (begin (backtrace-get-frame-start)))
+    (when (plist-get view :show-flags)
+      (save-excursion
+        (goto-char begin)
+        (let ((props (backtrace-get-text-properties begin))
+              (inhibit-read-only t)
+              (standard-output (current-buffer)))
+          (delete-char backtrace--flags-width)
+          (backtrace--print-flags (nth (backtrace-get-index) backtrace-frames)
+                                  view)
+          (add-text-properties begin (point) props))))))
+
+(defun backtrace--filter-visible (beg end &optional _delete)
+  "Return the visible text between BEG and END."
+  (let ((result ""))
+    (while (< beg end)
+      (let ((next (next-single-char-property-change beg 'invisible)))
+        (unless (get-char-property beg 'invisible)
+          (setq result (concat result (buffer-substring beg (min end next)))))
+        (setq beg next)))
+    result))
+
+;;; The mode definition
+
+(define-derived-mode backtrace-mode special-mode "Backtrace"
+  "Generic major mode for examining an Elisp stack backtrace.
+This mode can be used directly, or other major modes can be
+derived from it, using `define-derived-mode'.
+
+In this major mode, the buffer contains some optional lines of
+header text followed by backtrace frames, each consisting of one
+or more whole lines.
+
+Letters in this mode do not insert themselves; instead they are
+commands.
+\\<backtrace-mode-map>
+\\{backtrace-mode-map}
+
+A mode which inherits from Backtrace mode, or a command which
+creates a backtrace-mode buffer, should usually do the following:
+
+ - Set `backtrace-revert-hook', if the buffer contents need
+   to be specially recomputed prior to `revert-buffer'.
+ - Maybe set `backtrace-insert-header-function' to a function to create
+   header text for the buffer.
+ - Set `backtrace-frames' (see below).
+ - Maybe modify `backtrace-view' (see below).
+ - Maybe set `backtrace-print-function'.
+
+A command which creates or switches to a Backtrace mode buffer,
+such as `ert-results-pop-to-backtrace-for-test-at-point', should
+initialize `backtrace-frames' to a list of `backtrace-frame'
+objects (`backtrace-get-frames' is provided for that purpose, if
+desired), and may optionally modify `backtrace-view', which is a
+plist describing the appearance of the backtrace.  Finally, it
+should call `backtrace-print'.
+
+`backtrace-print' calls `backtrace-insert-header-function'
+followed by `backtrace-print-frame', once for each stack frame."
+  :syntax-table emacs-lisp-mode-syntax-table
+  (when backtrace-fontify
+    (setq font-lock-defaults
+          '((backtrace-font-lock-keywords
+             backtrace-font-lock-keywords-1
+             backtrace-font-lock-keywords-2)
+            nil nil nil nil
+           (font-lock-syntactic-face-function
+            . lisp-font-lock-syntactic-face-function))))
+  (setq truncate-lines t)
+  (buffer-disable-undo)
+  ;; In debug.el, from 1998 to 2009 this was set to nil, reason stated
+  ;; was because of bytecode. Since 2009 it's been set to t, but the
+  ;; default is t so I think this isn't necessary.
+  ;; (set-buffer-multibyte t)
+  (setq-local revert-buffer-function #'backtrace-revert)
+  (setq-local filter-buffer-substring-function #'backtrace--filter-visible)
+  (setq-local indent-line-function 'lisp-indent-line)
+  (setq-local indent-region-function 'lisp-indent-region)
+  (add-hook 'xref-backend-functions #'backtrace--xref-backend nil t))
+
+(put 'backtrace-mode 'mode-class 'special)
+
+;;; Backtrace printing
+
+;;;###autoload
+(defun backtrace ()
+  "Print a trace of Lisp function calls currently active.
+Output stream used is value of `standard-output'."
+  (princ (backtrace-to-string (backtrace-get-frames 'backtrace)))
+  nil)
+
+(defun backtrace-to-string(&optional frames)
+  "Format FRAMES, a list of `backtrace-frame' objects, for output.
+Return the result as a string.  If FRAMES is nil, use all
+function calls currently active."
+  (unless frames (setq frames (backtrace-get-frames 'backtrace-to-string)))
+  (let ((backtrace-fontify nil))
+    (with-temp-buffer
+      (backtrace-mode)
+      (setq backtrace-view '(:show-flags t)
+            backtrace-frames frames
+            backtrace-print-function #'cl-prin1)
+      (backtrace-print)
+      (substring-no-properties (filter-buffer-substring (point-min)
+                                                        (point-max))))))
+
+(provide 'backtrace)
+
+;;; backtrace.el ends here
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 011965a..d0d1c3b 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2083,10 +2083,7 @@ This is like `cl-flet', but for macros instead of 
functions.
 
 \(fn ((NAME ARGLIST BODY...) ...) FORM...)"
   (declare (indent 1)
-           (debug
-            ((&rest (&define name (&rest arg) cl-declarations-or-string
-                             def-body))
-             cl-declarations body)))
+           (debug (cl-macrolet-expr)))
   (if (cdr bindings)
       `(cl-macrolet (,(car bindings)) (cl-macrolet ,(cdr bindings) ,@body))
     (if (null bindings) (macroexp-progn body)
diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el
index bf5b1e8..c63f5ac 100644
--- a/lisp/emacs-lisp/cl-print.el
+++ b/lisp/emacs-lisp/cl-print.el
@@ -55,10 +55,19 @@ call other entry points instead, such as `cl-prin1'."
   ;; we should only use it for objects which don't have nesting.
   (prin1 object stream))
 
+(cl-defgeneric cl-print-object-contents (_object _start _stream)
+  "Dispatcher to print the contents of OBJECT on STREAM.
+Print the contents starting with the item at START, without
+delimiters."
+  ;; Every cl-print-object method which can print an ellipsis should
+  ;; have a matching cl-print-object-contents method to expand an
+  ;; ellipsis.
+  (error "Missing cl-print-object-contents method"))
+
 (cl-defmethod cl-print-object ((object cons) stream)
   (if (and cl-print--depth (natnump print-level)
            (> cl-print--depth print-level))
-      (princ "..." stream)
+      (cl-print-insert-ellipsis object 0 stream)
     (let ((car (pop object))
           (count 1))
       (if (and print-quoted
@@ -84,23 +93,60 @@ call other entry points instead, such as `cl-prin1'."
           (princ " " stream)
           (if (or (not (natnump print-length)) (> print-length count))
               (cl-print-object (pop object) stream)
-            (princ "..." stream)
+            (cl-print-insert-ellipsis object print-length stream)
             (setq object nil))
           (cl-incf count))
         (when object
           (princ " . " stream) (cl-print-object object stream))
         (princ ")" stream)))))
 
+(cl-defmethod cl-print-object-contents ((object cons) _start stream)
+  (let ((count 0))
+    (while (and (consp object)
+                (not (cond
+                      (cl-print--number-table
+                       (numberp (gethash object cl-print--number-table)))
+                      ((memq object cl-print--currently-printing))
+                      (t (push object cl-print--currently-printing)
+                         nil))))
+      (unless (zerop count)
+        (princ " " stream))
+      (if (or (not (natnump print-length)) (> print-length count))
+          (cl-print-object (pop object) stream)
+        (cl-print-insert-ellipsis object print-length stream)
+        (setq object nil))
+      (cl-incf count))
+    (when object
+      (princ " . " stream) (cl-print-object object stream))))
+
 (cl-defmethod cl-print-object ((object vector) stream)
-  (princ "[" stream)
-  (let ((count (length object)))
-    (dotimes (i (if (natnump print-length)
-                    (min print-length count) count))
-      (unless (zerop i) (princ " " stream))
-      (cl-print-object (aref object i) stream))
-    (when (and (natnump print-length) (< print-length count))
-      (princ " ..." stream)))
-  (princ "]" stream))
+  (if (and cl-print--depth (natnump print-level)
+           (> cl-print--depth print-level))
+      (cl-print-insert-ellipsis object 0 stream)
+    (princ "[" stream)
+    (let* ((len (length object))
+           (limit (if (natnump print-length)
+                      (min print-length len) len)))
+      (dotimes (i limit)
+        (unless (zerop i) (princ " " stream))
+        (cl-print-object (aref object i) stream))
+      (when (< limit len)
+        (princ " " stream)
+        (cl-print-insert-ellipsis object limit stream)))
+    (princ "]" stream)))
+
+(cl-defmethod cl-print-object-contents ((object vector) start stream)
+  (let* ((len (length object))
+         (limit (if (natnump print-length)
+                    (min (+ start print-length) len) len))
+         (i start))
+    (while (< i limit)
+      (unless (= i start) (princ " " stream))
+      (cl-print-object (aref object i) stream)
+      (cl-incf i))
+    (when (< limit len)
+      (princ " " stream)
+      (cl-print-insert-ellipsis object limit stream))))
 
 (cl-defmethod cl-print-object ((object hash-table) stream)
   (princ "#<hash-table " stream)
@@ -199,21 +245,135 @@ into a button whose action shows the function's 
disassembly.")
     (princ ")" stream)))
 
 (cl-defmethod cl-print-object ((object cl-structure-object) stream)
-  (princ "#s(" stream)
+  (if (and cl-print--depth (natnump print-level)
+           (> cl-print--depth print-level))
+      (cl-print-insert-ellipsis object 0 stream)
+    (princ "#s(" stream)
+    (let* ((class (cl-find-class (type-of object)))
+           (slots (cl--struct-class-slots class))
+           (len (length slots))
+           (limit (if (natnump print-length)
+                      (min print-length len) len)))
+      (princ (cl--struct-class-name class) stream)
+      (dotimes (i limit)
+        (let ((slot (aref slots i)))
+          (princ " :" stream)
+          (princ (cl--slot-descriptor-name slot) stream)
+          (princ " " stream)
+          (cl-print-object (aref object (1+ i)) stream)))
+      (when (< limit len)
+        (princ " " stream)
+        (cl-print-insert-ellipsis object limit stream)))
+    (princ ")" stream)))
+
+(cl-defmethod cl-print-object-contents ((object cl-structure-object) start 
stream)
   (let* ((class (cl-find-class (type-of object)))
          (slots (cl--struct-class-slots class))
-         (count (length slots)))
-    (princ (cl--struct-class-name class) stream)
-    (dotimes (i (if (natnump print-length)
-                    (min print-length count) count))
+         (len (length slots))
+         (limit (if (natnump print-length)
+                    (min (+ start print-length) len) len))
+         (i start))
+    (while (< i limit)
       (let ((slot (aref slots i)))
-        (princ " :" stream)
+        (unless (= i start) (princ " " stream))
+        (princ ":" stream)
         (princ (cl--slot-descriptor-name slot) stream)
         (princ " " stream)
-        (cl-print-object (aref object (1+ i)) stream)))
-    (when (and (natnump print-length) (< print-length count))
-      (princ " ..." stream)))
-  (princ ")" stream))
+        (cl-print-object (aref object (1+ i)) stream))
+      (cl-incf i))
+    (when (< limit len)
+      (princ " " stream)
+      (cl-print-insert-ellipsis object limit stream))))
+
+(cl-defmethod cl-print-object ((object string) stream)
+  (unless stream (setq stream standard-output))
+  (let* ((has-properties (or (text-properties-at 0 object)
+                             (next-property-change 0 object)))
+         (len (length object))
+         (limit (if (natnump print-length) (min print-length len) len)))
+    (if (and has-properties
+             cl-print--depth
+             (natnump print-level)
+             (> cl-print--depth print-level))
+        (cl-print-insert-ellipsis object 0 stream)
+      ;; Print all or part of the string
+      (when has-properties
+        (princ "#(" stream))
+      (if (= limit len)
+          (prin1 (if has-properties (substring-no-properties object) object)
+                 stream)
+        (let ((part (concat (substring-no-properties object 0 limit) "...")))
+          (prin1 part stream)
+          (when (bufferp stream)
+            (with-current-buffer stream
+              (cl-print-propertize-ellipsis object limit
+                                            (- (point) 4)
+                                            (- (point) 1) stream)))))
+      ;; Print the property list.
+      (when has-properties
+        (let* ((interval-limit (and (natnump print-length)
+                                    (max 1 (/ print-length 3))))
+               (interval-count 0)
+               (start-pos (if (text-properties-at 0 object)
+                              0 (next-property-change 0 object)))
+               (end-pos (next-property-change start-pos object len)))
+          (while (and (or (null interval-limit)
+                          (< interval-count interval-limit))
+                      (< start-pos len))
+            (let ((props (text-properties-at start-pos object)))
+              (when props
+                (princ " " stream) (princ start-pos stream)
+                (princ " " stream) (princ end-pos stream)
+                (princ " " stream) (cl-print-object props stream)
+                (cl-incf interval-count))
+              (setq start-pos end-pos
+                    end-pos (next-property-change start-pos object len))))
+          (when (< start-pos len)
+            (princ " " stream)
+            (cl-print-insert-ellipsis object (list start-pos) stream)))
+        (princ ")" stream)))))
+
+(cl-defmethod cl-print-object-contents ((object string) start stream)
+  ;; If START is an integer, it is an index into the string, and the
+  ;; ellipsis that needs to be expanded is part of the string.  If
+  ;; START is a cons, its car is an index into the string, and the
+  ;; ellipsis that needs to be expanded is in the property list.
+  (let* ((len (length object)))
+    (if (atom start)
+        ;; Print part of the string.
+        (let* ((limit (if (natnump print-length)
+                          (min (+ start print-length) len) len))
+               (substr (substring-no-properties object start limit))
+               (printed (prin1-to-string substr))
+               (trimmed (substring printed 1 (1- (length printed)))))
+          (princ trimmed)
+          (when (< limit len)
+            (cl-print-insert-ellipsis object limit stream)))
+
+      ;; Print part of the property list.
+      (let* ((first t)
+             (interval-limit (and (natnump print-length)
+                                  (max 1 (/ print-length 3))))
+             (interval-count 0)
+             (start-pos (car start))
+             (end-pos (next-property-change start-pos object len)))
+        (while (and (or (null interval-limit)
+                        (< interval-count interval-limit))
+                    (< start-pos len))
+          (let ((props (text-properties-at start-pos object)))
+            (when props
+              (if first
+                  (setq first nil)
+                (princ " " stream))
+              (princ start-pos stream)
+              (princ " " stream) (princ end-pos stream)
+              (princ " " stream) (cl-print-object props stream)
+              (cl-incf interval-count))
+            (setq start-pos end-pos
+                  end-pos (next-property-change start-pos object len))))
+        (when (< start-pos len)
+          (princ " " stream)
+          (cl-print-insert-ellipsis object (list start-pos) stream))))))
 
 ;;; Circularity and sharing.
 
@@ -275,8 +435,17 @@ into a button whose action shows the function's 
disassembly.")
                  (push cdr stack)
                  (push car stack))
                 ((pred stringp)
-                 ;; We presumably won't print its text-properties.
-                 nil)
+                 (let* ((len (length object))
+                        (start (if (text-properties-at 0 object)
+                                   0 (next-property-change 0 object)))
+                        (end (and start
+                                  (next-property-change start object len))))
+                   (while (and start (< start len))
+                     (let ((props (text-properties-at start object)))
+                       (when props
+                         (push props stack))
+                       (setq start end
+                             end (next-property-change start object len))))))
                 ((or (pred arrayp) (pred byte-code-function-p))
                  ;; FIXME: Inefficient for char-tables!
                  (dotimes (i (length object))
@@ -291,6 +460,48 @@ into a button whose action shows the function's 
disassembly.")
         (cl-print--find-sharing object print-number-table)))
     print-number-table))
 
+(defun cl-print-insert-ellipsis (object start stream)
+  "Print \"...\" to STREAM with the `cl-print-ellipsis' text property.
+Save state in the text property in order to print the elided part
+of OBJECT later.  START should be 0 if the whole OBJECT is being
+elided, otherwise it should be an index or other pointer into the
+internals of OBJECT which can be passed to
+`cl-print-object-contents' at a future time."
+  (unless stream (setq stream standard-output))
+  (let ((ellipsis-start (and (bufferp stream)
+                             (with-current-buffer stream (point)))))
+    (princ "..." stream)
+    (when ellipsis-start
+      (with-current-buffer stream
+        (cl-print-propertize-ellipsis object start ellipsis-start (point)
+                                      stream)))))
+
+(defun cl-print-propertize-ellipsis (object start beg end stream)
+  "Add the `cl-print-ellipsis' property between BEG and END.
+STREAM should be a buffer.  OBJECT and START are as described in
+`cl-print-insert-ellipsis'."
+  (let ((value (list object start cl-print--number-table
+                     cl-print--currently-printing)))
+    (with-current-buffer stream
+      (put-text-property beg end 'cl-print-ellipsis value stream))))
+
+;;;###autoload
+(defun cl-print-expand-ellipsis (value stream)
+  "Print the expansion of an ellipsis to STREAM.
+VALUE should be the value of the `cl-print-ellipsis' text property
+which was attached to the ellipsis by `cl-prin1'."
+  (let ((cl-print--depth 1)
+        (object (nth 0 value))
+        (start (nth 1 value))
+        (cl-print--number-table (nth 2 value))
+        (print-number-table (nth 2 value))
+        (cl-print--currently-printing (nth 3 value)))
+    (when (eq object (car cl-print--currently-printing))
+      (pop cl-print--currently-printing))
+    (if (equal start 0)
+        (cl-print-object object stream)
+      (cl-print-object-contents object start stream))))
+
 ;;;###autoload
 (defun cl-prin1 (object &optional stream)
   "Print OBJECT on STREAM according to its type.
@@ -313,5 +524,45 @@ node `(elisp)Output Variables'."
     (cl-prin1 object (current-buffer))
     (buffer-string)))
 
+;;;###autoload
+(defun cl-print-to-string-with-limit (print-function value limit)
+  "Return a string containing a printed representation of VALUE.
+Attempt to get the length of the returned string under LIMIT
+characters with appropriate settings of `print-level' and
+`print-length.'  Use PRINT-FUNCTION to print, which should take
+the arguments VALUE and STREAM and which should respect
+`print-length' and `print-level'.  LIMIT may be nil or zero in
+which case PRINT-FUNCTION will be called with `print-level' and
+`print-length' bound to nil.
+
+Use this function with `cl-prin1' to print an object,
+abbreviating it with ellipses to fit within a size limit.  Use
+this function with `cl-prin1-expand-ellipsis' to expand an
+ellipsis, abbreviating the expansion to stay within a size
+limit."
+  (setq limit (and (natnump limit)
+                   (not (zerop limit))
+                   limit))
+  ;; Since this is used by the debugger when stack space may be
+  ;; limited, if you increase print-level here, add more depth in
+  ;; call_debugger (bug#31919).
+  (let* ((print-length (when limit (min limit 50)))
+         (print-level (when limit (min 8 (truncate (log limit)))))
+         (delta (when limit
+                  (max 1 (truncate (/ print-length print-level))))))
+    (with-temp-buffer
+      (catch 'done
+        (while t
+          (erase-buffer)
+          (funcall print-function value (current-buffer))
+          ;; Stop when either print-level is too low or the value is
+          ;; successfully printed in the space allowed.
+          (when (or (not limit)
+                    (< (- (point-max) (point-min)) limit)
+                    (= print-level 2))
+            (throw 'done (buffer-string)))
+          (cl-decf print-level)
+          (cl-decf print-length delta))))))
+
 (provide 'cl-print)
 ;;; cl-print.el ends here
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 0efaa63..7fc2b41 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -28,6 +28,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'backtrace)
 (require 'button)
 
 (defgroup debugger nil
@@ -133,6 +134,25 @@ where CAUSE can be:
 - exit: called because of exit of a flagged function.
 - error: called because of `debug-on-error'.")
 
+(cl-defstruct (debugger--buffer-state
+            (:constructor debugger--save-buffer-state
+                          (&aux (mode     major-mode)
+                                (header   backtrace-insert-header-function)
+                                (frames   backtrace-frames)
+                                (content  (buffer-string))
+                                (pos      (point)))))
+  mode header frames content pos)
+
+(defun debugger--restore-buffer-state (state)
+  (unless (derived-mode-p (debugger--buffer-state-mode state))
+    (funcall (debugger--buffer-state-mode state)))
+  (setq backtrace-insert-header-function (debugger--buffer-state-header state)
+        backtrace-frames (debugger--buffer-state-frames state))
+  (let ((inhibit-read-only t))
+    (erase-buffer)
+    (insert (debugger--buffer-state-content state)))
+  (goto-char (debugger--buffer-state-pos state)))
+
 ;;;###autoload
 (setq debugger 'debug)
 ;;;###autoload
@@ -174,7 +194,7 @@ first will be printed into the backtrace buffer."
          (debugger-previous-state
            (if (get-buffer "*Backtrace*")
                (with-current-buffer (get-buffer "*Backtrace*")
-                 (list major-mode (buffer-string)))))
+                 (debugger--save-buffer-state))))
           (debugger-args args)
          (debugger-buffer (get-buffer-create "*Backtrace*"))
          (debugger-old-buffer (current-buffer))
@@ -236,7 +256,8 @@ first will be printed into the backtrace buffer."
                            (window-total-height debugger-window)))
                      (error nil)))
                (setq debugger-previous-window debugger-window))
-             (debugger-mode)
+              (unless (derived-mode-p 'debugger-mode)
+               (debugger-mode))
              (debugger-setup-buffer debugger-args)
              (when noninteractive
                ;; If the backtrace is long, save the beginning
@@ -280,15 +301,14 @@ first will be printed into the backtrace buffer."
             (setq debugger-previous-window nil))
           ;; Restore previous state of debugger-buffer in case we were
           ;; in a recursive invocation of the debugger, otherwise just
-          ;; erase the buffer and put it into fundamental mode.
+          ;; erase the buffer.
          (when (buffer-live-p debugger-buffer)
            (with-current-buffer debugger-buffer
-             (let ((inhibit-read-only t))
-               (erase-buffer)
-               (if (null debugger-previous-state)
-                   (fundamental-mode)
-                 (insert (nth 1 debugger-previous-state))
-                 (funcall (nth 0 debugger-previous-state))))))
+             (if debugger-previous-state
+                  (debugger--restore-buffer-state debugger-previous-state)
+                (setq backtrace-insert-header-function nil)
+                (setq backtrace-frames nil)
+                (backtrace-print))))
          (with-timeout-unsuspend debugger-with-timeout-suspend)
          (set-match-data debugger-outer-match-data)))
       (setq debug-on-next-call debugger-step-after-exit)
@@ -301,112 +321,80 @@ first will be printed into the backtrace buffer."
      (message "Error in debug printer: %S" err)
      (prin1 obj stream))))
 
-(defun debugger-insert-backtrace (frames do-xrefs)
-  "Format and insert the backtrace FRAMES at point.
-Make functions into cross-reference buttons if DO-XREFS is non-nil."
-  (let ((standard-output (current-buffer))
-        (eval-buffers eval-buffer-list))
-    (require 'help-mode)     ; Define `help-function-def' button type.
-    (pcase-dolist (`(,evald ,fun ,args ,flags) frames)
-      (insert (if (plist-get flags :debug-on-exit)
-                  "* " "  "))
-      (let ((fun-file (and do-xrefs (symbol-file fun 'defun)))
-            (fun-pt (point)))
-        (cond
-         ((and evald (not debugger-stack-frame-as-list))
-          (debugger--print fun)
-          (if args (debugger--print args) (princ "()")))
-         (t
-          (debugger--print (cons fun args))
-          (cl-incf fun-pt)))
-        (when fun-file
-          (make-text-button fun-pt (+ fun-pt (length (symbol-name fun)))
-                            :type 'help-function-def
-                            'help-args (list fun fun-file))))
-      ;; After any frame that uses eval-buffer, insert a line that
-      ;; states the buffer position it's reading at.
-      (when (and eval-buffers (memq fun '(eval-buffer eval-region)))
-        (insert (format "  ; Reading at buffer position %d"
-                        ;; This will get the wrong result if there are
-                        ;; two nested eval-region calls for the same
-                        ;; buffer.  That's not a very useful case.
-                        (with-current-buffer (pop eval-buffers)
-                          (point)))))
-      (insert "\n"))))
-
 (defun debugger-setup-buffer (args)
   "Initialize the `*Backtrace*' buffer for entry to the debugger.
-That buffer should be current already."
-  (setq buffer-read-only nil)
-  (erase-buffer)
-  (set-buffer-multibyte t)             ;Why was it nil ?  -stef
-  (setq buffer-undo-list t)
+That buffer should be current already and in debugger-mode."
+  (setq backtrace-frames (nthcdr
+                          ;; Remove debug--implement-debug-on-entry and the
+                          ;; advice's `apply' frame.
+                          (if (eq (car args) 'debug) 3 1)
+                          (backtrace-get-frames 'debug)))
+  (when (eq (car-safe args) 'exit)
+    (setq debugger-value (nth 1 args))
+    (setf (cl-getf (backtrace-frame-flags (car backtrace-frames))
+                   :debug-on-exit)
+          nil))
+
+  (setq backtrace-view (plist-put backtrace-view :show-flags t)
+        backtrace-insert-header-function (lambda ()
+                                           (debugger--insert-header args))
+        backtrace-print-function debugger-print-function)
+  (backtrace-print)
+  ;; Place point on "stack frame 0" (bug#15101).
+  (goto-char (point-min))
+  (search-forward ":" (line-end-position) t)
+  (when (and (< (point) (line-end-position))
+             (= (char-after) ?\s))
+    (forward-char)))
+
+(defun debugger--insert-header (args)
+  "Insert the header for the debugger's Backtrace buffer.
+Include the reason for debugger entry from ARGS."
   (insert "Debugger entered")
-  (let ((frames (nthcdr
-                 ;; Remove debug--implement-debug-on-entry and the
-                 ;; advice's `apply' frame.
-                 (if (eq (car args) 'debug) 3 1)
-                 (backtrace-frames 'debug)))
-        (print-escape-newlines t)
-        (print-escape-control-characters t)
-        ;; If you increase print-level, add more depth in call_debugger.
-        (print-level 8)
-        (print-length 50)
-        (pos (point)))
-    (pcase (car args)
-      ;; lambda is for debug-on-call when a function call is next.
-      ;; debug is for debug-on-entry function called.
-      ((or `lambda `debug)
-       (insert "--entering a function:\n")
-       (setq pos (1- (point))))
-      ;; Exiting a function.
-      (`exit
-       (insert "--returning value: ")
-       (setq pos (point))
-       (setq debugger-value (nth 1 args))
-       (debugger--print debugger-value (current-buffer))
-       (setf (cl-getf (nth 3 (car frames)) :debug-on-exit) nil)
-       (insert ?\n))
-      ;; Watchpoint triggered.
-      ((and `watchpoint (let `(,symbol ,newval . ,details) (cdr args)))
-       (insert
-        "--"
-        (pcase details
-          (`(makunbound nil) (format "making %s void" symbol))
-          (`(makunbound ,buffer) (format "killing local value of %s in buffer 
%s"
-                                         symbol buffer))
-          (`(defvaralias ,_) (format "aliasing %s to %s" symbol newval))
-          (`(let ,_) (format "let-binding %s to %S" symbol newval))
-          (`(unlet ,_) (format "ending let-binding of %s" symbol))
-          (`(set nil) (format "setting %s to %S" symbol newval))
-          (`(set ,buffer) (format "setting %s in buffer %s to %S"
-                                  symbol buffer newval))
-          (_ (error "unrecognized watchpoint triggered %S" (cdr args))))
-        ": ")
-       (setq pos (point))
-       (insert ?\n))
-      ;; Debugger entered for an error.
-      (`error
-       (insert "--Lisp error: ")
-       (setq pos (point))
-       (debugger--print (nth 1 args) (current-buffer))
-       (insert ?\n))
-      ;; debug-on-call, when the next thing is an eval.
-      (`t
-       (insert "--beginning evaluation of function call form:\n")
-       (setq pos (1- (point))))
-      ;; User calls debug directly.
-      (_
-       (insert ": ")
-       (setq pos (point))
-       (debugger--print
-                (if (eq (car args) 'nil)
-                    (cdr args) args)
-                (current-buffer))
-       (insert ?\n)))
-    (debugger-insert-backtrace frames t)
-    ;; Place point on "stack frame 0" (bug#15101).
-    (goto-char pos)))
+  (pcase (car args)
+    ;; lambda is for debug-on-call when a function call is next.
+    ;; debug is for debug-on-entry function called.
+    ((or `lambda `debug)
+     (insert "--entering a function:\n"))
+    ;; Exiting a function.
+    (`exit
+     (insert "--returning value: ")
+     (insert (backtrace-print-to-string debugger-value))
+     (insert ?\n))
+    ;; Watchpoint triggered.
+    ((and `watchpoint (let `(,symbol ,newval . ,details) (cdr args)))
+     (insert
+      "--"
+      (pcase details
+        (`(makunbound nil) (format "making %s void" symbol))
+        (`(makunbound ,buffer) (format "killing local value of %s in buffer %s"
+                                       symbol buffer))
+        (`(defvaralias ,_) (format "aliasing %s to %s" symbol newval))
+        (`(let ,_) (format "let-binding %s to %s" symbol
+                           (backtrace-print-to-string newval)))
+        (`(unlet ,_) (format "ending let-binding of %s" symbol))
+        (`(set nil) (format "setting %s to %s" symbol
+                            (backtrace-print-to-string newval)))
+        (`(set ,buffer) (format "setting %s in buffer %s to %s"
+                                symbol buffer
+                                (backtrace-print-to-string newval)))
+        (_ (error "unrecognized watchpoint triggered %S" (cdr args))))
+      ": ")
+     (insert ?\n))
+    ;; Debugger entered for an error.
+    (`error
+     (insert "--Lisp error: ")
+     (insert (backtrace-print-to-string (nth 1 args)))
+     (insert ?\n))
+    ;; debug-on-call, when the next thing is an eval.
+    (`t
+     (insert "--beginning evaluation of function call form:\n"))
+    ;; User calls debug directly.
+    (_
+     (insert ": ")
+     (insert (backtrace-print-to-string (if (eq (car args) 'nil)
+                                            (cdr args) args)))
+     (insert ?\n))))
 
 
 (defun debugger-step-through ()
@@ -426,12 +414,12 @@ Enter another debugger on next entry to eval, apply or 
funcall."
   (unless debugger-may-continue
     (error "Cannot continue"))
   (message "Continuing.")
-  (save-excursion
-    ;; Check to see if we've flagged some frame for debug-on-exit, in which
-    ;; case we'll probably come back to the debugger soon.
-    (goto-char (point-min))
-    (if (re-search-forward "^\\* " nil t)
-        (setq debugger-will-be-back t)))
+
+  ;; Check to see if we've flagged some frame for debug-on-exit, in which
+  ;; case we'll probably come back to the debugger soon.
+  (dolist (frame backtrace-frames)
+    (when (plist-get (backtrace-frame-flags frame) :debug-on-exit)
+      (setq debugger-will-be-back t)))
   (exit-recursive-edit))
 
 (defun debugger-return-value (val)
@@ -446,12 +434,11 @@ will be used, such as in a debug on exit from a frame."
   (setq debugger-value val)
   (princ "Returning " t)
   (debugger--print debugger-value)
-  (save-excursion
     ;; Check to see if we've flagged some frame for debug-on-exit, in which
     ;; case we'll probably come back to the debugger soon.
-    (goto-char (point-min))
-    (if (re-search-forward "^\\* " nil t)
-        (setq debugger-will-be-back t)))
+  (dolist (frame backtrace-frames)
+    (when (plist-get (backtrace-frame-flags frame) :debug-on-exit)
+      (setq debugger-will-be-back t)))
   (exit-recursive-edit))
 
 (defun debugger-jump ()
@@ -473,63 +460,40 @@ removes itself from that hook."
 
 (defun debugger-frame-number (&optional skip-base)
   "Return number of frames in backtrace before the one point points at."
-  (save-excursion
-    (beginning-of-line)
-    (if (looking-at " *;;;\\|[a-z]")
-       (error "This line is not a function call"))
-    (let ((opoint (point))
-         (count 0))
-      (unless skip-base
+  (let ((index (backtrace-get-index))
+        (count 0))
+    (unless index
+      (error "This line is not a function call"))
+    (unless skip-base
         (while (not (eq (cadr (backtrace-frame count)) 'debug))
           (setq count (1+ count)))
         ;; Skip debug--implement-debug-on-entry frame.
         (when (eq 'debug--implement-debug-on-entry
                   (cadr (backtrace-frame (1+ count))))
           (setq count (+ 2 count))))
-      (goto-char (point-min))
-      (when (looking-at "Debugger entered--\\(Lisp error\\|returning 
value\\):")
-       (goto-char (match-end 0))
-       (forward-sexp 1))
-      (forward-line 1)
-      (while (progn
-              (forward-char 2)
-              (cond ((debugger--locals-visible-p)
-                     (goto-char (next-single-char-property-change
-                                 (point) 'locals-visible)))
-                    ((= (following-char) ?\()
-                     (forward-sexp 1))
-                    (t
-                     (forward-sexp 2)))
-              (forward-line 1)
-              (<= (point) opoint))
-       (if (looking-at " *;;;")
-           (forward-line 1))
-       (setq count (1+ count)))
-      count)))
+    (+ count index)))
 
 (defun debugger-frame ()
   "Request entry to debugger when this frame exits.
 Applies to the frame whose line point is on in the backtrace."
   (interactive)
   (backtrace-debug (debugger-frame-number) t)
-  (beginning-of-line)
-  (if (= (following-char) ? )
-      (let ((inhibit-read-only t))
-       (delete-char 1)
-       (insert ?*)))
-  (beginning-of-line))
+  (setf
+   (cl-getf (backtrace-frame-flags (nth (backtrace-get-index) 
backtrace-frames))
+            :debug-on-exit)
+   t)
+  (backtrace-update-flags))
 
 (defun debugger-frame-clear ()
   "Do not enter debugger when this frame exits.
 Applies to the frame whose line point is on in the backtrace."
   (interactive)
   (backtrace-debug (debugger-frame-number) nil)
-  (beginning-of-line)
-  (if (= (following-char) ?*)
-      (let ((inhibit-read-only t))
-       (delete-char 1)
-       (insert ? )))
-  (beginning-of-line))
+  (setf
+   (cl-getf (backtrace-frame-flags (nth (backtrace-get-index) 
backtrace-frames))
+            :debug-on-exit)
+   nil)
+  (backtrace-update-flags))
 
 (defmacro debugger-env-macro (&rest body)
   "Run BODY in original environment."
@@ -564,69 +528,10 @@ The environment used is the one when entering the 
activation frame at point."
           (let ((str (eval-expression-print-format val)))
             (if str (princ str t))))))))
 
-(defun debugger--locals-visible-p ()
-  "Are the local variables of the current stack frame visible?"
-  (save-excursion
-    (move-to-column 2)
-    (get-text-property (point) 'locals-visible)))
-
-(defun debugger--insert-locals (locals)
-  "Insert the local variables LOCALS at point."
-  (cond ((null locals)
-        (insert "\n    [no locals]"))
-       (t
-        (let ((print-escape-newlines t))
-          (dolist (s+v locals)
-            (let ((symbol (car s+v))
-                  (value (cdr s+v)))
-              (insert "\n    ")
-              (prin1 symbol (current-buffer))
-              (insert " = ")
-              (debugger--print value (current-buffer))))))))
-
-(defun debugger--show-locals ()
-  "For the frame at point, insert locals and add text properties."
-  (let* ((nframe (1+ (debugger-frame-number 'skip-base)))
-        (base (debugger--backtrace-base))
-        (locals (backtrace--locals nframe base))
-        (inhibit-read-only t))
-    (save-excursion
-      (let ((start (progn
-                    (move-to-column 2)
-                    (point))))
-       (end-of-line)
-       (debugger--insert-locals locals)
-       (add-text-properties start (point) '(locals-visible t))))))
-
-(defun debugger--hide-locals ()
-  "Delete local variables and remove the text property."
-  (let* ((col (current-column))
-        (end (progn
-               (move-to-column 2)
-               (next-single-char-property-change (point) 'locals-visible)))
-        (start (previous-single-char-property-change end 'locals-visible))
-        (inhibit-read-only t))
-    (remove-text-properties start end '(locals-visible))
-    (goto-char start)
-    (end-of-line)
-    (delete-region (point) end)
-    (move-to-column col)))
-
-(defun debugger-toggle-locals ()
-  "Show or hide local variables of the current stack frame."
-  (interactive)
-  (cond ((debugger--locals-visible-p)
-        (debugger--hide-locals))
-       (t
-        (debugger--show-locals))))
-
 
 (defvar debugger-mode-map
-  (let ((map (make-keymap))
-       (menu-map (make-sparse-keymap)))
-    (set-keymap-parent map button-buffer-map)
-    (suppress-keymap map)
-    (define-key map "-" 'negative-argument)
+  (let ((map (make-keymap)))
+    (set-keymap-parent map backtrace-mode-map)
     (define-key map "b" 'debugger-frame)
     (define-key map "c" 'debugger-continue)
     (define-key map "j" 'debugger-jump)
@@ -634,63 +539,47 @@ The environment used is the one when entering the 
activation frame at point."
     (define-key map "u" 'debugger-frame-clear)
     (define-key map "d" 'debugger-step-through)
     (define-key map "l" 'debugger-list-functions)
-    (define-key map "h" 'describe-mode)
-    (define-key map "q" 'top-level)
+    (define-key map "q" 'debugger-quit)
     (define-key map "e" 'debugger-eval-expression)
-    (define-key map "v" 'debugger-toggle-locals) ; "v" is for "variables".
-    (define-key map " " 'next-line)
     (define-key map "R" 'debugger-record-expression)
-    (define-key map "\C-m" 'debug-help-follow)
     (define-key map [mouse-2] 'push-button)
-    (define-key map [menu-bar debugger] (cons "Debugger" menu-map))
-    (define-key menu-map [deb-top]
-      '(menu-item "Quit" top-level
-                 :help "Quit debugging and return to top level"))
-    (define-key menu-map [deb-s0] '("--"))
-    (define-key menu-map [deb-descr]
-      '(menu-item "Describe Debugger Mode" describe-mode
-                 :help "Display documentation for debugger-mode"))
-    (define-key menu-map [deb-hfol]
-      '(menu-item "Help Follow" debug-help-follow
-                 :help "Follow cross-reference"))
-    (define-key menu-map [deb-nxt]
-      '(menu-item "Next Line" next-line
-                 :help "Move cursor down"))
-    (define-key menu-map [deb-s1] '("--"))
-    (define-key menu-map [deb-lfunc]
-      '(menu-item "List debug on entry functions" debugger-list-functions
-                 :help "Display a list of all the functions now set to debug 
on entry"))
-    (define-key menu-map [deb-fclear]
-      '(menu-item "Cancel debug frame" debugger-frame-clear
-                 :help "Do not enter debugger when this frame exits"))
-    (define-key menu-map [deb-frame]
-      '(menu-item "Debug frame" debugger-frame
-                 :help "Request entry to debugger when this frame exits"))
-    (define-key menu-map [deb-s2] '("--"))
-    (define-key menu-map [deb-ret]
-      '(menu-item "Return value..." debugger-return-value
-                 :help "Continue, specifying value to return."))
-    (define-key menu-map [deb-rec]
-      '(menu-item "Display and Record Expression" debugger-record-expression
-                 :help "Display a variable's value and record it in 
`*Backtrace-record*' buffer"))
-    (define-key menu-map [deb-eval]
-      '(menu-item "Eval Expression..." debugger-eval-expression
-                 :help "Eval an expression, in an environment like that 
outside the debugger"))
-    (define-key menu-map [deb-jump]
-      '(menu-item "Jump" debugger-jump
-                 :help "Continue to exit from this frame, with all 
debug-on-entry suspended"))
-    (define-key menu-map [deb-cont]
-      '(menu-item "Continue" debugger-continue
-       :help "Continue, evaluating this expression without stopping"))
-    (define-key menu-map [deb-step]
-      '(menu-item "Step through" debugger-step-through
-       :help "Proceed, stepping through subexpressions of this expression"))
+    (easy-menu-define nil map ""
+      '("Debugger"
+        ["Step through" debugger-step-through
+         :help "Proceed, stepping through subexpressions of this expression"]
+        ["Continue" debugger-continue
+         :help "Continue, evaluating this expression without stopping"]
+        ["Jump" debugger-jump
+         :help "Continue to exit from this frame, with all debug-on-entry 
suspended"]
+        ["Eval Expression..." debugger-eval-expression
+         :help "Eval an expression, in an environment like that outside the 
debugger"]
+        ["Display and Record Expression" debugger-record-expression
+         :help "Display a variable's value and record it in 
`*Backtrace-record*' buffer"]
+        ["Return value..." debugger-return-value
+         :help "Continue, specifying value to return."]
+        "--"
+        ["Debug frame" debugger-frame
+         :help "Request entry to debugger when this frame exits"]
+        ["Cancel debug frame" debugger-frame-clear
+         :help "Do not enter debugger when this frame exits"]
+        ["List debug on entry functions" debugger-list-functions
+         :help "Display a list of all the functions now set to debug on entry"]
+        "--"
+        ["Next Line" next-line
+         :help "Move cursor down"]
+        ["Help for Symbol" backtrace-help-follow-symbol
+         :help "Show help for symbol at point"]
+        ["Describe Debugger Mode" describe-mode
+         :help "Display documentation for debugger-mode"]
+        "--"
+        ["Quit" debugger-quit
+         :help "Quit debugging and return to top level"]))
     map))
 
 (put 'debugger-mode 'mode-class 'special)
 
-(define-derived-mode debugger-mode fundamental-mode "Debugger"
-  "Mode for backtrace buffers, selected in debugger.
+(define-derived-mode debugger-mode backtrace-mode "Debugger"
+  "Mode for debugging Emacs Lisp using a backtrace.
 \\<debugger-mode-map>
 A line starts with `*' if exiting that frame will call the debugger.
 Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'.
@@ -704,8 +593,6 @@ which functions will enter the debugger when called.
 
 Complete list of commands:
 \\{debugger-mode-map}"
-  (setq truncate-lines t)
-  (set-syntax-table emacs-lisp-mode-syntax-table)
   (add-hook 'kill-buffer-hook
             (lambda () (if (> (recursion-depth) 0) (top-level)))
             nil t)
@@ -732,27 +619,6 @@ Complete list of commands:
             (buffer-substring (line-beginning-position 0)
                               (line-end-position 0)))))
 
-(defun debug-help-follow (&optional pos)
-  "Follow cross-reference at POS, defaulting to point.
-
-For the cross-reference format, see `help-make-xrefs'."
-  (interactive "d")
-  ;; Ideally we'd just do (call-interactively 'help-follow) except that this
-  ;; assumes we're already in a *Help* buffer and reuses it, so it ends up
-  ;; incorrectly "reusing" the *Backtrace* buffer to show the help info.
-  (unless pos
-    (setq pos (point)))
-  (unless (push-button pos)
-    ;; check if the symbol under point is a function or variable
-    (let ((sym
-          (intern
-           (save-excursion
-             (goto-char pos) (skip-syntax-backward "w_")
-             (buffer-substring (point)
-                               (progn (skip-syntax-forward "w_")
-                                      (point)))))))
-      (when (or (boundp sym) (fboundp sym) (facep sym))
-        (describe-symbol sym)))))
 
 ;; When you change this, you may also need to change the number of
 ;; frames that the debugger skips.
@@ -853,6 +719,13 @@ To specify a nil argument interactively, exit with an 
empty minibuffer."
           ;;(princ "be set to debug on entry, even if it is in the list.")
           )))))
 
+(defun debugger-quit ()
+  "Quit debugging and return to the top level."
+  (interactive)
+  (if (= (recursion-depth) 0)
+      (quit-window)
+    (top-level)))
+
 (defun debug--implement-debug-watch (symbol newval op where)
   "Conditionally call the debugger.
 This function is called when SYMBOL's value is modified."
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index e759c5b..fa418c6 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -52,6 +52,7 @@
 
 ;;; Code:
 
+(require 'backtrace)
 (require 'macroexp)
 (require 'cl-lib)
 (eval-when-compile (require 'pcase))
@@ -206,8 +207,7 @@ Use this with caution since it is not debugged."
   "Non-nil if Edebug should unwrap results of expressions.
 That is, Edebug will try to remove its own instrumentation from the result.
 This is useful when debugging macros where the results of expressions
-are instrumented expressions.  But don't do this when results might be
-circular or an infinite loop will result."
+are instrumented expressions."
   :type 'boolean
   :group 'edebug)
 
@@ -1198,6 +1198,8 @@ purpose by adding an entry to this alist, and setting
 (defvar edebug-inside-func)  ;; whether code is inside function context.
 ;; Currently def-form sets this to nil; def-body sets it to t.
 
+(defvar edebug--cl-macrolet-defs) ;; Fully defined below.
+
 (defun edebug-interactive-p-name ()
   ;; Return a unique symbol for the variable used to store the
   ;; status of interactive-p for this function.
@@ -1263,25 +1265,59 @@ purpose by adding an entry to this alist, and setting
 (defun edebug-unwrap (sexp)
   "Return the unwrapped SEXP or return it as is if it is not wrapped.
 The SEXP might be the result of wrapping a body, which is a list of
-expressions; a `progn' form will be returned enclosing these forms."
-  (if (consp sexp)
-      (cond
-       ((eq 'edebug-after (car sexp))
-       (nth 3 sexp))
-       ((eq 'edebug-enter (car sexp))
-        (macroexp-progn (nthcdr 2 (nth 1 (nth 3 sexp)))))
-       (t sexp);; otherwise it is not wrapped, so just return it.
-       )
-    sexp))
+expressions; a `progn' form will be returned enclosing these forms.
+Does not unwrap inside vectors, records, structures, or hash tables."
+  (pcase sexp
+    (`(edebug-after ,_before-form ,_after-index ,form)
+     form)
+    (`(lambda ,args (edebug-enter ',_sym ,_arglist
+                                  (function (lambda nil . ,body))))
+     `(lambda ,args ,@body))
+    (`(closure ,env ,args (edebug-enter ',_sym ,_arglist
+                                        (function (lambda nil . ,body))))
+     `(closure ,env ,args ,@body))
+    (`(edebug-enter ',_sym ,_args (function (lambda nil . ,body)))
+     (macroexp-progn body))
+    (_ sexp)))
 
 (defun edebug-unwrap* (sexp)
   "Return the SEXP recursively unwrapped."
+  (let ((ht (make-hash-table :test 'eq)))
+    (edebug--unwrap1 sexp ht)))
+
+(defun edebug--unwrap1 (sexp hash-table)
+  "Unwrap SEXP using HASH-TABLE of things already unwrapped.
+HASH-TABLE contains the results of unwrapping cons cells within
+SEXP, which are reused to avoid infinite loops when SEXP is or
+contains a circular object."
   (let ((new-sexp (edebug-unwrap sexp)))
     (while (not (eq sexp new-sexp))
       (setq sexp new-sexp
            new-sexp (edebug-unwrap sexp)))
     (if (consp new-sexp)
-       (mapcar #'edebug-unwrap* new-sexp)
+       (let ((result (gethash new-sexp hash-table nil)))
+         (unless result
+           (let ((remainder new-sexp)
+                 current)
+             (setq result (cons nil nil)
+                   current result)
+             (while
+                 (progn
+                   (puthash remainder current hash-table)
+                   (setf (car current)
+                         (edebug--unwrap1 (car remainder) hash-table))
+                   (setq remainder (cdr remainder))
+                   (cond
+                    ((atom remainder)
+                     (setf (cdr current)
+                           (edebug--unwrap1 remainder hash-table))
+                     nil)
+                    ((gethash remainder hash-table nil)
+                     (setf (cdr current) (gethash remainder hash-table nil))
+                     nil)
+                    (t (setq current
+                             (setf (cdr current) (cons nil nil)))))))))
+         result)
       new-sexp)))
 
 
@@ -1463,6 +1499,11 @@ expressions; a `progn' form will be returned enclosing 
these forms."
   ;; Helper for edebug-list-form
   (let ((spec (get-edebug-spec head)))
     (cond
+     ;; Treat cl-macrolet bindings like macros with no spec.
+     ((member head edebug--cl-macrolet-defs)
+      (if edebug-eval-macro-args
+         (edebug-forms cursor)
+       (edebug-sexps cursor)))
      (spec
       (cond
        ((consp spec)
@@ -1651,6 +1692,9 @@ expressions; a `progn' form will be returned enclosing 
these forms."
                ;; (function . edebug-match-function)
                (lambda-expr . edebug-match-lambda-expr)
                 (cl-generic-method-args . edebug-match-cl-generic-method-args)
+                (cl-macrolet-expr . edebug-match-cl-macrolet-expr)
+                (cl-macrolet-name . edebug-match-cl-macrolet-name)
+                (cl-macrolet-body . edebug-match-cl-macrolet-body)
                (&not . edebug-match-&not)
                (&key . edebug-match-&key)
                (place . edebug-match-place)
@@ -1954,6 +1998,43 @@ expressions; a `progn' form will be returned enclosing 
these forms."
     (edebug-move-cursor cursor)
     (list args)))
 
+(defvar edebug--cl-macrolet-defs nil
+  "List of symbols found within the bindings of enclosing `cl-macrolet' 
forms.")
+(defvar edebug--current-cl-macrolet-defs nil
+  "List of symbols found within the bindings of the current `cl-macrolet' 
form.")
+
+(defun edebug-match-cl-macrolet-expr (cursor)
+  "Match a `cl-macrolet' form at CURSOR."
+  (let (edebug--current-cl-macrolet-defs)
+    (edebug-match cursor
+                  '((&rest (&define cl-macrolet-name cl-macro-list
+                                    cl-declarations-or-string
+                                    def-body))
+                    cl-declarations cl-macrolet-body))))
+
+(defun edebug-match-cl-macrolet-name (cursor)
+  "Match the name in a `cl-macrolet' binding at CURSOR.
+Collect the names in `edebug--cl-macrolet-defs' where they
+will be checked by `edebug-list-form-args' and treated as
+macros without a spec."
+  (let ((name (edebug-top-element-required cursor "Expected name")))
+    (when (not (symbolp name))
+      (edebug-no-match cursor "Bad name:" name))
+    ;; Change edebug-def-name to avoid conflicts with
+    ;; names at global scope.
+    (setq edebug-def-name (gensym "edebug-anon"))
+    (edebug-move-cursor cursor)
+    (push name edebug--current-cl-macrolet-defs)
+    (list name)))
+
+(defun edebug-match-cl-macrolet-body (cursor)
+  "Match the body of a `cl-macrolet' expression at CURSOR.
+Put the definitions collected in `edebug--current-cl-macrolet-defs'
+into `edebug--cl-macrolet-defs' which is checked in `edebug-list-form-args'."
+  (let ((edebug--cl-macrolet-defs (nconc edebug--current-cl-macrolet-defs
+                                         edebug--cl-macrolet-defs)))
+    (edebug-match-body cursor)))
+
 (defun edebug-match-arg (cursor)
   ;; set the def-args bound in edebug-defining-form
   (let ((edebug-arg (edebug-top-element-required cursor "Expected arg")))
@@ -3611,7 +3692,7 @@ be installed in `emacs-lisp-mode-map'.")
 
     ;; misc
     (define-key map "?" 'edebug-help)
-    (define-key map "d" 'edebug-backtrace)
+    (define-key map "d" 'edebug-pop-to-backtrace)
 
     (define-key map "-" 'negative-argument)
 
@@ -3869,8 +3950,10 @@ Global commands prefixed by `global-edebug-prefix':
 ;; (setq debugger 'debug)  ; use the standard debugger
 
 ;; Note that debug and its utilities must be byte-compiled to work,
-;; since they depend on the backtrace looking a certain way.  But
-;; edebug is not dependent on this, yet.
+;; since they depend on the backtrace looking a certain way.  Edebug
+;; will work if not byte-compiled, but it will not be able correctly
+;; remove its instrumentation from backtraces unless it is
+;; byte-compiled.
 
 (defun edebug (&optional arg-mode &rest args)
   "Replacement for `debug'.
@@ -3900,49 +3983,136 @@ Otherwise call `debug' normally."
     (apply #'debug arg-mode args)
     ))
 
-
-(defun edebug-backtrace ()
-  "Display a non-working backtrace.  Better than nothing..."
+;;; Backtrace buffer
+
+(defvar-local edebug-backtrace-frames nil
+  "Stack frames of the current Edebug Backtrace buffer without instrumentation.
+This should be a list of `edebug---frame' objects.")
+(defvar-local edebug-instrumented-backtrace-frames nil
+  "Stack frames of the current Edebug Backtrace buffer with instrumentation.
+This should be a list of `edebug---frame' objects.")
+
+;; Data structure for backtrace frames with information
+;; from Edebug instrumentation found in the backtrace.
+(cl-defstruct
+    (edebug--frame
+     (:constructor edebug--make-frame)
+     (:include backtrace-frame))
+  def-name before-index after-index)
+
+(defun edebug-pop-to-backtrace ()
+  "Display the current backtrace in a `backtrace-mode' window."
   (interactive)
   (if (or (not edebug-backtrace-buffer)
          (null (buffer-name edebug-backtrace-buffer)))
       (setq edebug-backtrace-buffer
-           (generate-new-buffer "*Backtrace*"))
+           (generate-new-buffer "*Edebug Backtrace*"))
     ;; Else, could just display edebug-backtrace-buffer.
     )
-  (with-output-to-temp-buffer (buffer-name edebug-backtrace-buffer)
-    (setq edebug-backtrace-buffer standard-output)
-    (let ((print-escape-newlines t)
-         (print-length 50)     ; FIXME cf edebug-safe-prin1-to-string
-         last-ok-point)
-      (backtrace)
-
-      ;; Clean up the backtrace.
-      ;; Not quite right for current edebug scheme.
-      (set-buffer edebug-backtrace-buffer)
-      (setq truncate-lines t)
-      (goto-char (point-min))
-      (setq last-ok-point (point))
-      (if t (progn
-
-      ;; Delete interspersed edebug internals.
-      (while (re-search-forward "^  (?edebug" nil t)
-       (beginning-of-line)
-       (cond
-        ((looking-at "^  (edebug-after")
-         ;; Previous lines may contain code, so just delete this line.
-         (setq last-ok-point (point))
-         (forward-line 1)
-         (delete-region last-ok-point (point)))
-
-        ((looking-at (if debugger-stack-frame-as-list
-                          "^  (edebug"
-                        "^  edebug"))
-         (forward-line 1)
-         (delete-region last-ok-point (point))
-         )))
-      )))))
+  (pop-to-buffer edebug-backtrace-buffer)
+  (unless (derived-mode-p 'backtrace-mode)
+    (backtrace-mode)
+    (add-hook 'backtrace-goto-source-functions 'edebug--backtrace-goto-source))
+  (setq edebug-instrumented-backtrace-frames
+        (backtrace-get-frames 'edebug-debugger
+                              :constructor #'edebug--make-frame)
+        edebug-backtrace-frames (edebug--strip-instrumentation
+                                 edebug-instrumented-backtrace-frames)
+        backtrace-frames edebug-backtrace-frames)
+  (backtrace-print)
+  (goto-char (point-min)))
+
+(defun edebug--strip-instrumentation (frames)
+  "Return a new list of backtrace frames with instrumentation removed.
+Remove frames for Edebug's functions and the lambdas in
+`edebug-enter' wrappers.  Fill in the def-name, before-index
+and after-index fields in both FRAMES and the returned list
+of deinstrumented frames, for those frames where the source
+code location is known."
+  (let (skip-next-lambda def-name before-index after-index results
+        (index (length frames)))
+    (dolist (frame (reverse frames))
+      (let ((new-frame (copy-edebug--frame frame))
+            (fun (edebug--frame-fun frame))
+            (args (edebug--frame-args frame)))
+        (cl-decf index)
+        (pcase fun
+          ('edebug-enter
+          (setq skip-next-lambda t
+                 def-name (nth 0 args)))
+          ('edebug-after
+           (setq before-index (if (consp (nth 0 args))
+                                  (nth 1 (nth 0 args))
+                                (nth 0 args))
+                 after-index (nth 1 args)))
+          ((pred edebug--symbol-not-prefixed-p)
+           (edebug--unwrap-frame new-frame)
+           (edebug--add-source-info new-frame def-name before-index 
after-index)
+           (edebug--add-source-info frame def-name before-index after-index)
+           (push new-frame results)
+           (setq before-index nil
+                 after-index nil))
+          (`(,(or 'lambda 'closure) . ,_)
+          (unless skip-next-lambda
+             (edebug--unwrap-frame new-frame)
+             (edebug--add-source-info frame def-name before-index after-index)
+             (edebug--add-source-info new-frame def-name before-index 
after-index)
+             (push new-frame results))
+          (setq before-index nil
+                 after-index nil
+                 skip-next-lambda nil)))))
+    results))
+
+(defun edebug--symbol-not-prefixed-p (sym)
+  "Return non-nil if SYM is a symbol not prefixed by \"edebug-\"."
+  (and (symbolp sym)
+       (not (string-prefix-p "edebug-" (symbol-name sym)))))
+
+(defun edebug--unwrap-frame (frame)
+  "Remove Edebug's instrumentation from FRAME.
+Strip it from the function and any unevaluated arguments."
+  (setf (edebug--frame-fun frame) (edebug-unwrap* (edebug--frame-fun frame)))
+  (unless (edebug--frame-evald frame)
+    (let (results)
+      (dolist (arg (edebug--frame-args frame))
+        (push (edebug-unwrap* arg) results))
+      (setf (edebug--frame-args frame) (nreverse results)))))
+
+(defun edebug--add-source-info (frame def-name before-index after-index)
+  "Update FRAME with the additional info needed by an edebug--frame.
+Save DEF-NAME, BEFORE-INDEX and AFTER-INDEX in FRAME."
+  (when (and before-index def-name)
+    (setf (edebug--frame-flags frame)
+          (plist-put (copy-sequence (edebug--frame-flags frame))
+                     :source-available t)))
+  (setf (edebug--frame-def-name frame) (and before-index def-name))
+  (setf (edebug--frame-before-index frame) before-index)
+  (setf (edebug--frame-after-index frame) after-index))
+
+(defun edebug--backtrace-goto-source ()
+  (let* ((index (backtrace-get-index))
+         (frame (nth index backtrace-frames)))
+    (when (edebug--frame-def-name frame)
+      (let* ((data (get (edebug--frame-def-name frame) 'edebug))
+             (marker (nth 0 data))
+             (offsets (nth 2 data)))
+        (pop-to-buffer (marker-buffer marker))
+        (goto-char (+ (marker-position marker)
+                      (aref offsets (edebug--frame-before-index frame))))))))
+
+(defun edebug-backtrace-show-instrumentation ()
+  "Show Edebug's instrumentation in an Edebug Backtrace buffer."
+  (interactive)
+  (unless (eq backtrace-frames edebug-instrumented-backtrace-frames)
+    (setq backtrace-frames edebug-instrumented-backtrace-frames)
+    (revert-buffer)))
 
+(defun edebug-backtrace-hide-instrumentation ()
+  "Hide Edebug's instrumentation in an Edebug Backtrace buffer."
+  (interactive)
+  (unless (eq backtrace-frames edebug-backtrace-frames)
+    (setq backtrace-frames edebug-backtrace-frames)
+    (revert-buffer)))
 
 ;;; Trace display
 
@@ -4116,7 +4286,7 @@ It is removed when you hit any char."
      ["Bounce to Current Point" edebug-bounce-point t]
      ["View Outside Windows" edebug-view-outside t]
      ["Previous Result" edebug-previous-result t]
-     ["Show Backtrace" edebug-backtrace t]
+     ["Show Backtrace" edebug-pop-to-backtrace t]
      ["Display Freq Count" edebug-display-freq-count t])
 
     ("Eval"
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index cad2104..eb9695d 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -60,6 +60,7 @@
 (require 'cl-lib)
 (require 'button)
 (require 'debug)
+(require 'backtrace)
 (require 'easymenu)
 (require 'ewoc)
 (require 'find-func)
@@ -677,13 +678,6 @@ and is displayed in front of the value of MESSAGE-FORM."
 (cl-defstruct (ert-test-aborted-with-non-local-exit
                (:include ert-test-result)))
 
-(defun ert--print-backtrace (backtrace do-xrefs)
-  "Format the backtrace BACKTRACE to the current buffer."
-  (let ((print-escape-newlines t)
-        (print-level 8)
-        (print-length 50))
-    (debugger-insert-backtrace backtrace do-xrefs)))
-
 ;; A container for the state of the execution of a single test and
 ;; environment data needed during its execution.
 (cl-defstruct ert--test-execution-info
@@ -732,7 +726,7 @@ run.  ARGS are the arguments to `debugger'."
               ;; use.
               ;;
               ;; Grab the frames above the debugger.
-              (backtrace (cdr (backtrace-frames debugger)))
+              (backtrace (cdr (backtrace-get-frames debugger)))
               (infos (reverse ert--infos)))
          (setf (ert--test-execution-info-result info)
                (cl-ecase type
@@ -1406,9 +1400,8 @@ Returns the stats object."
               (ert-test-result-with-condition
                (message "Test %S backtrace:" (ert-test-name test))
                (with-temp-buffer
-                 (ert--print-backtrace
-                  (ert-test-result-with-condition-backtrace result)
-                  nil)
+                 (insert (backtrace-to-string
+                          (ert-test-result-with-condition-backtrace result)))
                  (if (not ert-batch-backtrace-right-margin)
                      (message "%s"
                               (buffer-substring-no-properties (point-min)
@@ -2450,20 +2443,20 @@ To be used in the ERT results buffer."
     (cl-etypecase result
       (ert-test-passed (error "Test passed, no backtrace available"))
       (ert-test-result-with-condition
-       (let ((backtrace (ert-test-result-with-condition-backtrace result))
-             (buffer (get-buffer-create "*ERT Backtrace*")))
+       (let ((buffer (get-buffer-create "*ERT Backtrace*")))
          (pop-to-buffer buffer)
-         (let ((inhibit-read-only t))
-           (buffer-disable-undo)
-           (erase-buffer)
-           (ert-simple-view-mode)
-           (set-buffer-multibyte t)     ; mimic debugger-setup-buffer
-           (setq truncate-lines t)
-           (ert--print-backtrace backtrace t)
-           (goto-char (point-min))
-           (insert (substitute-command-keys "Backtrace for test `"))
-           (ert-insert-test-name-button (ert-test-name test))
-           (insert (substitute-command-keys "':\n"))))))))
+         (unless (derived-mode-p 'backtrace-mode)
+           (backtrace-mode))
+         (setq backtrace-insert-header-function
+               (lambda () (ert--insert-backtrace-header (ert-test-name test)))
+               backtrace-frames (ert-test-result-with-condition-backtrace 
result))
+         (backtrace-print)
+         (goto-char (point-min)))))))
+
+(defun ert--insert-backtrace-header (name)
+  (insert (substitute-command-keys "Backtrace for test `"))
+  (ert-insert-test-name-button name)
+  (insert (substitute-command-keys "':\n")))
 
 (defun ert-results-pop-to-messages-for-test-at-point ()
   "Display the part of the *Messages* buffer generated during the test at 
point.
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 4e5b1a7..afb7cbd 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -517,6 +517,16 @@ This will generate compile-time constants from BINDINGS."
 (defvar lisp-cl-font-lock-keywords lisp-cl-font-lock-keywords-1
   "Default expressions to highlight in Lisp modes.")
 
+;; Support backtrace mode.
+(defconst lisp-el-font-lock-keywords-for-backtraces lisp-el-font-lock-keywords
+  "Default highlighting from Emacs Lisp mod used in Backtrace mode.")
+(defconst lisp-el-font-lock-keywords-for-backtraces-1 
lisp-el-font-lock-keywords-1
+  "Subdued highlighting from Emacs Lisp mode used in Backtrace mode.")
+(defconst lisp-el-font-lock-keywords-for-backtraces-2
+  (remove (assoc 'lisp--match-hidden-arg lisp-el-font-lock-keywords-2)
+          lisp-el-font-lock-keywords-2)
+  "Gaudy highlighting from Emacs Lisp mode used in Backtrace mode.")
+
 (defun lisp-string-in-doc-position-p (listbeg startpos)
    "Return true if a doc string may occur at STARTPOS inside a list.
 LISTBEG is the position of the start of the innermost list
@@ -1196,7 +1206,21 @@ ENDPOS is encountered."
                   (if endpos endpos
                     ;; Get error now if we don't have a complete sexp
                     ;; after point.
-                    (save-excursion (forward-sexp 1) (point)))))
+                    (save-excursion
+                      (let ((eol (line-end-position)))
+                        (forward-sexp 1)
+                        ;; We actually look for a sexp which ends
+                        ;; after the current line so that we properly
+                        ;; indent things like #s(...).  This might not
+                        ;; be needed if Bug#15998 is fixed.
+                        (condition-case ()
+                            (while (and (< (point) eol) (not (eobp)))
+                              (forward-sexp 1))
+                          ;; But don't signal an error for incomplete
+                          ;; sexps following the first complete sexp
+                          ;; after point.
+                          (scan-error nil)))
+                      (point)))))
     (save-excursion
       (while (let ((indent (lisp-indent-calc-next parse-state))
                    (ppss (lisp-indent-state-ppss parse-state)))
diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index 61c04ff..a61c0ad 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -257,10 +257,15 @@ C-g to quit (cancel the whole command);
 ;; either long or short answers.
 
 ;; For backward compatibility check if short y/n answers are preferred.
-(defcustom read-answer-short (eq (symbol-function 'yes-or-no-p) 'y-or-n-p)
-  "If non-nil, accept short answers to the question."
-  :type 'boolean
-  :version "27.1"
+(defcustom read-answer-short 'auto
+  "If non-nil, `read-answer' accepts single-character answers.
+If t, accept short (single key-press) answers to the question.
+If nil, require long answers.  If `auto', accept short answers if
+the function cell of `yes-or-no-p' is set to `y-or-on-p'."
+  :type '(choice (const :tag "Accept short answers" t)
+                 (const :tag "Require long answer" nil)
+                 (const :tag "Guess preference" auto))
+  :version "26.2"
   :group 'minibuffer)
 
 (defconst read-answer-map--memoize (make-hash-table :weakness 'key :test 
'equal))
@@ -290,8 +295,9 @@ When `read-answer-short' is non-nil, accept short answers.
 Return a long answer even in case of accepting short ones.
 
 When `use-dialog-box' is t, pop up a dialog window to get user input."
-  (custom-reevaluate-setting 'read-answer-short)
-  (let* ((short read-answer-short)
+  (let* ((short (if (eq read-answer-short 'auto)
+                    (eq (symbol-function 'yes-or-no-p) 'y-or-n-p)
+                  read-answer-short))
          (answers-with-help
           (if (assoc "help" answers)
               answers
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index ec380e6..5180a07 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -407,6 +407,7 @@ in the minibuffer:
        nil))))
 
 (put 'eshell/cd 'eshell-no-numeric-conversions t)
+(put 'eshell/cd 'eshell-filename-arguments t)
 
 (defun eshell-add-to-dir-ring (path)
   "Add PATH to the last-dir-ring, if applicable."
@@ -470,6 +471,7 @@ in the minibuffer:
   nil)
 
 (put 'eshell/pushd 'eshell-no-numeric-conversions t)
+(put 'eshell/pushd 'eshell-filename-arguments t)
 
 ;;; popd [+n]
 (defun eshell/popd (&rest args)
@@ -500,6 +502,7 @@ in the minibuffer:
   nil)
 
 (put 'eshell/popd 'eshell-no-numeric-conversions t)
+(put 'eshell/pop 'eshell-filename-arguments t)
 
 (defun eshell/dirs (&optional if-verbose)
   "Implementation of dirs in Lisp."
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 900b289..2b568a9 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -334,6 +334,7 @@ instead."
     (apply 'eshell-do-ls args)))
 
 (put 'eshell/ls 'eshell-no-numeric-conversions t)
+(put 'eshell/ls 'eshell-filename-arguments t)
 
 (declare-function eshell-glob-regexp "em-glob" (pattern))
 
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index a18fb85..c912c15 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -307,6 +307,7 @@ Remove (unlink) the FILE(s).")
    nil))
 
 (put 'eshell/rm 'eshell-no-numeric-conversions t)
+(put 'eshell/rm 'eshell-filename-arguments t)
 
 (defun eshell/mkdir (&rest args)
   "Implementation of mkdir in Lisp."
@@ -324,6 +325,7 @@ Create the DIRECTORY(ies), if they do not already exist.")
    nil))
 
 (put 'eshell/mkdir 'eshell-no-numeric-conversions t)
+(put 'eshell/mkdir 'eshell-filename-arguments t)
 
 (defun eshell/rmdir (&rest args)
   "Implementation of rmdir in Lisp."
@@ -340,6 +342,7 @@ Remove the DIRECTORY(ies), if they are empty.")
    nil))
 
 (put 'eshell/rmdir 'eshell-no-numeric-conversions t)
+(put 'eshell/rmdir 'eshell-filename-arguments t)
 
 (defvar no-dereference)
 
@@ -524,6 +527,7 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
                             eshell-mv-overwrite-files))))
 
 (put 'eshell/mv 'eshell-no-numeric-conversions t)
+(put 'eshell/mv 'eshell-filename-arguments t)
 
 (defun eshell/cp (&rest args)
   "Implementation of cp in Lisp."
@@ -561,6 +565,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.")
                           eshell-cp-overwrite-files preserve)))
 
 (put 'eshell/cp 'eshell-no-numeric-conversions t)
+(put 'eshell/cp 'eshell-filename-arguments t)
 
 (defun eshell/ln (&rest args)
   "Implementation of ln in Lisp."
@@ -593,6 +598,7 @@ with `--symbolic'.  When creating hard links, each TARGET 
must exist.")
                             eshell-ln-overwrite-files))))
 
 (put 'eshell/ln 'eshell-no-numeric-conversions t)
+(put 'eshell/ln 'eshell-filename-arguments t)
 
 (defun eshell/cat (&rest args)
   "Implementation of cat in Lisp.
@@ -645,6 +651,7 @@ Concatenate FILE(s), or standard input, to standard 
output.")
      (setq eshell-ensure-newline-p nil))))
 
 (put 'eshell/cat 'eshell-no-numeric-conversions t)
+(put 'eshell/cat 'eshell-filename-arguments t)
 
 ;; special front-end functions for compilation-mode buffers
 
@@ -927,6 +934,8 @@ Summarize disk usage of each FILE, recursively for 
directories.")
             (eshell-print (concat (eshell-du-size-string size)
                                   "total\n"))))))))
 
+(put 'eshell/du 'eshell-filename-arguments t)
+
 (defvar eshell-time-start nil)
 
 (defun eshell-show-elapsed-time ()
@@ -1029,6 +1038,7 @@ Show wall-clock time elapsed during execution of 
COMMAND.")
   nil)
 
 (put 'eshell/diff 'eshell-no-numeric-conversions t)
+(put 'eshell/diff 'eshell-filename-arguments t)
 
 (defvar locate-history-list)
 
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 61c0ebc..92cac61 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -1304,27 +1304,36 @@ messages, and errors."
   "Insert Lisp OBJECT, using ARGS if a function."
   (catch 'eshell-external               ; deferred to an external command
     (let* ((eshell-ensure-newline-p (eshell-interactive-output-p))
-          (result
-           (if (functionp object)
-               (progn
-                 (setq eshell-last-arguments args
-                       eshell-last-command-name
-                       (concat "#<function " (symbol-name object) ">"))
-                 ;; if any of the arguments are flagged as numbers
-                 ;; waiting for conversion, convert them now
-                 (unless (get object 'eshell-no-numeric-conversions)
-                   (while args
-                     (let ((arg (car args)))
-                       (if (and (stringp arg)
-                                (> (length arg) 0)
-                                (not (text-property-not-all
-                                      0 (length arg) 'number t arg)))
-                           (setcar args (string-to-number arg))))
-                     (setq args (cdr args))))
-                 (eshell-apply object eshell-last-arguments))
-             (setq eshell-last-arguments args
-                   eshell-last-command-name "#<Lisp object>")
-             (eshell-eval object))))
+           (result
+            (if (functionp object)
+                (progn
+                  (setq eshell-last-arguments args
+                        eshell-last-command-name
+                        (concat "#<function " (symbol-name object) ">"))
+                  (let ((numeric (not (get object
+                                           'eshell-no-numeric-conversions)))
+                        (fname-args (get object 'eshell-filename-arguments)))
+                    (when (or numeric fname-args)
+                      (while args
+                        (let ((arg (car args)))
+                          (cond ((and numeric (stringp arg) (> (length arg) 0)
+                                      (text-property-any 0 (length arg)
+                                                         'number t arg))
+                                 ;; If any of the arguments are
+                                 ;; flagged as numbers waiting for
+                                 ;; conversion, convert them now.
+                                 (setcar args (string-to-number arg)))
+                                ((and fname-args (stringp arg)
+                                      (string-equal arg "~"))
+                                 ;; If any of the arguments match "~",
+                                 ;; prepend "./" to treat it as a
+                                 ;; regular file name.
+                                 (setcar args (concat "./" arg)))))
+                        (setq args (cdr args)))))
+                  (eshell-apply object eshell-last-arguments))
+              (setq eshell-last-arguments args
+                    eshell-last-command-name "#<Lisp object>")
+              (eshell-eval object))))
       (if (and eshell-ensure-newline-p
               (save-excursion
                 (goto-char eshell-last-output-end)
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index ba5182d..244cc7f 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -259,6 +259,7 @@ Adds the given PATH to $PATH.")
        (eshell-printn dir)))))
 
 (put 'eshell/addpath 'eshell-no-numeric-conversions t)
+(put 'eshell/addpath 'eshell-filename-arguments t)
 
 (defun eshell-script-interpreter (file)
   "Extract the script to run from FILE, if it has #!<interp> in it.
diff --git a/lisp/files.el b/lisp/files.el
index fae7900..0cb99d3 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2055,7 +2055,7 @@ started Emacs, set `abbreviated-home-dir' to nil so it 
will be recalculated)."
                         (save-match-data
                           (string-match "^[a-zA-`]:/$" filename))))
                (equal (get 'abbreviated-home-dir 'home)
-                      (expand-file-name "~")))
+                      (save-match-data (expand-file-name "~"))))
          (setq filename
                (concat "~"
                        (match-string 1 filename)
@@ -5660,6 +5660,21 @@ raised."
          (dolist (dir create-list)
             (files--ensure-directory dir)))))))
 
+(defun make-empty-file (filename &optional parents)
+  "Create an empty file FILENAME.
+Optional arg PARENTS, if non-nil then creates parent dirs as needed.
+
+If called interactively, then PARENTS is non-nil."
+  (interactive
+   (let ((filename (read-file-name "Create empty file: ")))
+     (list filename t)))
+  (when (and (file-exists-p filename) (null parents))
+    (signal 'file-already-exists `("File exists" ,filename)))
+  (let ((paren-dir (file-name-directory filename)))
+    (when (and paren-dir (not (file-exists-p paren-dir)))
+      (make-directory paren-dir parents)))
+  (write-region "" nil filename nil 0))
+
 (defconst directory-files-no-dot-files-regexp
   "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"
   "Regexp matching any file name except \".\" and \"..\".")
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index e562b30..ceb9842 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -4310,10 +4310,10 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
 if it was already present.
 
-If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
-will not be entered in the DEPENDENCIES table.  Otherwise duplicate
-Message-IDs will be renamed to a unique Message-ID before being
-entered.
+If `gnus-summary-ignore-duplicates' is non-nil then duplicate
+Message-IDs will not be entered in the DEPENDENCIES table.
+Otherwise duplicate Message-IDs will be renamed to a unique
+Message-ID before being entered.
 
 Returns HEADER if it was entered in the DEPENDENCIES.  Returns nil otherwise."
   (let* ((id (mail-header-id header))
diff --git a/lisp/international/fontset.el b/lisp/international/fontset.el
index a023d4f..d4ade3c 100644
--- a/lisp/international/fontset.el
+++ b/lisp/international/fontset.el
@@ -79,7 +79,7 @@
        ("cns11643.92p7-0" . chinese-cns11643-7)
        ("big5" . big5)
        ("viscii" . viscii)
-       ("tis620" . tis620-2533)
+       ("tis620" . thai-iso8859-11)
        ("microsoft-cp1251" . windows-1251)
        ("koi8-r" . koi8-r)
        ("jisx0213.2000-1" . japanese-jisx0213-1)
@@ -139,7 +139,7 @@
        (cyrillic-iso8859-5 . iso-8859-5)
        (greek-iso8859-7 . iso-8859-7)
        (arabic-iso8859-6 . iso-8859-6)
-       (thai-tis620 . tis620-2533)
+       (thai-tis620 . thai-iso8859-11)
        (latin-jisx0201 . jisx0201)
        (katakana-jisx0201 . jisx0201)
        (chinese-big5-1 . big5)
@@ -1233,11 +1233,12 @@ Done when `mouse-set-font' is called."
     (latin-iso8859-15 . latin)
     (latin-iso8859-16 . latin)
     (latin-jisx0201 . latin)
+    (thai-iso8859-11 . thai)
     (thai-tis620 . thai)
     (cyrillic-iso8859-5 . cyrillic)
     (arabic-iso8859-6 . arabic)
-    (greek-iso8859-7 . latin)
-    (hebrew-iso8859-8 . latin)
+    (greek-iso8859-7 . greek)
+    (hebrew-iso8859-8 . hebrew)
     (katakana-jisx0201 . kana)
     (chinese-gb2312 . han)
     (chinese-gbk . han)
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index cf6a8c7..2bde83f 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -300,8 +300,7 @@ wrong, use this command again to toggle back to the right 
mode."
         (cmd (key-binding keyseq))
         prefix)
     ;; read-key-sequence ignores quit, so make an explicit check.
-    ;; Like many places, this assumes quit == C-g, but it need not be.
-    (if (equal last-input-event ?\C-g)
+    (if (equal last-input-event (nth 3 (current-input-mode)))
        (keyboard-quit))
     (when (memq cmd '(universal-argument digit-argument))
       (call-interactively cmd)
@@ -314,16 +313,16 @@ wrong, use this command again to toggle back to the right 
mode."
        (let ((current-prefix-arg prefix-arg)
              ;; Have to bind `last-command-event' here so that
              ;; `digit-argument', for instance, can compute the
-             ;; prefix arg.
+             ;; `prefix-arg'.
              (last-command-event (aref keyseq 0)))
          (call-interactively cmd)))
 
       ;; This is the final call to `universal-argument-other-key', which
-      ;; set's the final `prefix-arg.
+      ;; sets the final `prefix-arg'.
       (let ((current-prefix-arg prefix-arg))
        (call-interactively cmd))
 
-      ;; Read the command to execute with the given prefix arg.
+      ;; Read the command to execute with the given `prefix-arg'.
       (setq prefix prefix-arg
            keyseq (read-key-sequence nil t)
            cmd (key-binding keyseq)))
diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el
index dc09570..a635c67 100644
--- a/lisp/international/mule-conf.el
+++ b/lisp/international/mule-conf.el
@@ -201,6 +201,7 @@
 ;; plus nbsp
 (define-iso-single-byte-charset 'iso-8859-11 'thai-iso8859-11
   "ISO/IEC 8859/11" "Latin/Thai" 166 ?T nil "8859-11")
+(define-charset-alias 'tis620-2533 'thai-iso8859-11)
 
 ;; 8859-12 doesn't (yet?) exist.
 
@@ -229,14 +230,6 @@
   :code-space [32 127]
   :code-offset #x0E00)
 
-;; Fixme: doc for this, c.f. above
-(define-charset 'tis620-2533
-  "TIS620.2533"
-  :short-name "TIS620.2533"
-  :ascii-compatible-p t
-  :code-space [0 255]
-  :superset '(ascii eight-bit-control (thai-tis620 . 128)))
-
 (define-charset 'jisx0201
   "JISX0201"
   :short-name "JISX0201"
diff --git a/lisp/international/mule-diag.el b/lisp/international/mule-diag.el
index 87a2e99..c9829e3 100644
--- a/lisp/international/mule-diag.el
+++ b/lisp/international/mule-diag.el
@@ -355,7 +355,8 @@ meanings of these arguments."
                     (:iso-revision-number "ISO revision number: "
                                           number-to-string)
                     (:supplementary-p
-                     "Used only as a parent of some other charset." nil)))
+                     "Used only as a parent or a subset of some other charset,
+or provided just for backward compatibility." nil)))
        (let ((val (get-charset-property charset (car elt))))
          (when val
            (if (cadr elt) (insert (cadr elt)))
diff --git a/lisp/language/thai.el b/lisp/language/thai.el
index a896fe5..c655845 100644
--- a/lisp/language/thai.el
+++ b/lisp/language/thai.el
@@ -36,7 +36,7 @@
   "8-bit encoding for ASCII (MSB=0) and Thai TIS620 (MSB=1)."
   :coding-type 'charset
   :mnemonic ?T
-  :charset-list '(tis620-2533))
+  :charset-list '(thai-iso8859-11))
 
 (define-coding-system-alias 'th-tis620 'thai-tis620)
 (define-coding-system-alias 'tis620 'thai-tis620)
@@ -47,7 +47,7 @@
          (charset thai-tis620)
          (coding-system thai-tis620 iso-8859-11 cp874)
          (coding-priority thai-tis620)
-         (nonascii-translation . tis620-2533)
+         (nonascii-translation . iso-8859-11)
          (input-method . "thai-kesmanee")
          (unibyte-display . thai-tis620)
          (features thai-util)
diff --git a/lisp/ldefs-boot.el b/lisp/ldefs-boot.el
index 5f26eba..3bd775f 100644
--- a/lisp/ldefs-boot.el
+++ b/lisp/ldefs-boot.el
@@ -176,12 +176,18 @@ Optional arg BUFFER-FILE overrides `buffer-file-name'.
 \(fn &optional FILE-NAME BUFFER-FILE)" nil nil)
 
 (autoload 'add-change-log-entry "add-log" "\
-Find change log file, and add an entry for today and an item for this file.
-Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
-name and email (stored in `add-log-full-name' and `add-log-mailing-address').
-
-Second arg FILE-NAME is file name of the change log.
-If nil, use the value of `change-log-default-name'.
+Find ChangeLog buffer, add an entry for today and an item for this file.
+Optional arg WHOAMI (interactive prefix) non-nil means prompt for
+user name and email (stored in `add-log-full-name'
+and `add-log-mailing-address').
+
+Second arg CHANGELOG-FILE-NAME is the file name of the change log.
+If nil, use the value of `change-log-default-name'.  If the file
+thus named exists, it is used for the new entry.  If it doesn't
+exist, it is created, unless `add-log-dont-create-changelog-file' is t,
+in which case a suitably named buffer that doesn't visit any file
+is used for keeping entries pertaining to CHANGELOG-FILE-NAME's
+directory.
 
 Third arg OTHER-WINDOW non-nil means visit in other window.
 
@@ -204,7 +210,7 @@ notices.
 Today's date is calculated according to `add-log-time-zone-rule' if
 non-nil, otherwise in local time.
 
-\(fn &optional WHOAMI FILE-NAME OTHER-WINDOW NEW-ENTRY 
PUT-NEW-ENTRY-ON-NEW-LINE)" t nil)
+\(fn &optional WHOAMI CHANGELOG-FILE-NAME OTHER-WINDOW NEW-ENTRY 
PUT-NEW-ENTRY-ON-NEW-LINE)" t nil)
 
 (autoload 'add-change-log-entry-other-window "add-log" "\
 Find change log file in other window and add entry and item.
@@ -577,9 +583,11 @@ Return t if `allout-mode' is active in current buffer.
 
 (autoload 'allout-mode "allout" "\
 Toggle Allout outline mode.
-With a prefix argument ARG, enable Allout outline mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Allout mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \\<allout-mode-map-value>
 Allout outline mode is a minor mode that provides extensive
@@ -890,9 +898,11 @@ See `allout-widgets-mode' for allout widgets mode 
features.")
 
 (autoload 'allout-widgets-mode "allout-widgets" "\
 Toggle Allout Widgets mode.
-With a prefix argument ARG, enable Allout Widgets mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Allout-Widgets mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Allout Widgets mode is an extension of Allout mode that provides
 graphical decoration of outline structure.  It is meant to
@@ -1300,7 +1310,12 @@ Entering array mode calls the function `array-mode-hook'.
 
 (autoload 'artist-mode "artist" "\
 Toggle Artist mode.
-With argument ARG, turn Artist mode on if ARG is positive.
+
+If called interactively, enable Artist mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 Artist lets you draw lines, squares, rectangles and poly-lines,
 ellipses and circles with your mouse and/or keyboard.
 
@@ -1571,9 +1586,6 @@ for a description of this minor mode.")
 
 (autoload 'autoarg-mode "autoarg" "\
 Toggle Autoarg mode, a global minor mode.
-With a prefix argument ARG, enable Autoarg mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
 
 \\<autoarg-mode-map>
 In Autoarg mode, digits are bound to `digit-argument', i.e. they
@@ -1607,9 +1619,11 @@ or call the function `autoarg-kp-mode'.")
 
 (autoload 'autoarg-kp-mode "autoarg" "\
 Toggle Autoarg-KP mode, a global minor mode.
-With a prefix argument ARG, enable Autoarg-KP mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Autoarg-Kp mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \\<autoarg-kp-mode-map>
 This is similar to `autoarg-mode' but rebinds the keypad keys
@@ -1663,9 +1677,11 @@ or call the function `auto-insert-mode'.")
 
 (autoload 'auto-insert-mode "autoinsert" "\
 Toggle Auto-insert mode, a global minor mode.
-With a prefix argument ARG, enable Auto-insert mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Auto-Insert mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Auto-insert mode is enabled, when new files are created you can
 insert a template for the file depending on the mode of the buffer.
@@ -1735,9 +1751,11 @@ should be non-nil).
 
 (autoload 'auto-revert-mode "autorevert" "\
 Toggle reverting buffer when the file changes (Auto-Revert Mode).
-With a prefix argument ARG, enable Auto-Revert Mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Auto-Revert mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Auto-Revert Mode is a minor mode that affects only the current
 buffer.  When enabled, it reverts the buffer when the file on
@@ -1762,9 +1780,11 @@ This function is designed to be added to hooks, for 
example:
 
 (autoload 'auto-revert-tail-mode "autorevert" "\
 Toggle reverting tail of buffer when the file grows.
-With a prefix argument ARG, enable Auto-Revert Tail Mode if ARG
-is positive, and disable it otherwise.  If called from Lisp,
-enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Auto-Revert-Tail mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Auto-Revert Tail Mode is enabled, the tail of the file is
 constantly followed, as with the shell command `tail -f'.  This
@@ -1803,9 +1823,11 @@ or call the function `global-auto-revert-mode'.")
 
 (autoload 'global-auto-revert-mode "autorevert" "\
 Toggle Global Auto-Revert Mode.
-With a prefix argument ARG, enable Global Auto-Revert Mode if ARG
-is positive, and disable it otherwise.  If called from Lisp,
-enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Global Auto-Revert mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Global Auto-Revert Mode is a global minor mode that reverts any
 buffer associated with a file when the file changes on disk.  Use
@@ -1921,9 +1943,11 @@ or call the function `display-battery-mode'.")
 
 (autoload 'display-battery-mode "battery" "\
 Toggle battery status display in mode line (Display Battery mode).
-With a prefix argument ARG, enable Display Battery mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Display-Battery mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 The text displayed in the mode line is controlled by
 `battery-mode-line-format' and `battery-status-function'.
@@ -2331,7 +2355,7 @@ BOOKMARK is usually a bookmark name (a string).  It can 
also be a
 bookmark record, but this is usually only done by programmatic callers.
 
 If DISPLAY-FUNC is non-nil, it is a function to invoke to display the
-bookmark.  It defaults to `switch-to-buffer'.  A typical value for
+bookmark.  It defaults to `pop-to-buffer-same-window'.  A typical value for
 DISPLAY-FUNC would be `switch-to-buffer-other-window'.
 
 \(fn BOOKMARK &optional DISPLAY-FUNC)" t nil)
@@ -2897,15 +2921,22 @@ columns on its right towards the left.
 
 (autoload 'bug-reference-mode "bug-reference" "\
 Toggle hyperlinking bug references in the buffer (Bug Reference mode).
-With a prefix argument ARG, enable Bug Reference mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Bug-Reference mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
 (autoload 'bug-reference-prog-mode "bug-reference" "\
 Like `bug-reference-mode', but only buttonize in comments and strings.
 
+If called interactively, enable Bug-Reference-Prog mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"bug-reference" '("bug-reference-")))
@@ -4691,9 +4722,11 @@ Prefix argument is the same as for `checkdoc-defun'
 
 (autoload 'checkdoc-minor-mode "checkdoc" "\
 Toggle automatic docstring checking (Checkdoc minor mode).
-With a prefix argument ARG, enable Checkdoc minor mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Checkdoc minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 In Checkdoc minor mode, the usual bindings for `eval-defun' which is
 bound to \\<checkdoc-minor-mode-map>\\[checkdoc-eval-defun] and 
`checkdoc-eval-current-buffer' are overridden to include
@@ -4933,6 +4966,11 @@ This can be needed when using code byte-compiled using 
the old
 macro-expansion of `cl-defstruct' that used vectors objects instead
 of record objects.
 
+If called interactively, enable Cl-Old-Struct-Compat mode if ARG is positive, 
and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"cl-lib" '("cl-")))
@@ -5150,7 +5188,7 @@ REGEXP-GROUP is the regular expression group in REGEXP to 
use.
 
 \(fn PROCESS COMMAND REGEXP REGEXP-GROUP)" nil nil)
 
-(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"comint" '("comint-" "send-invisible" "shell-strip-ctrl-m")))
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"comint" '("comint-")))
 
 ;;;***
 
@@ -5346,9 +5384,11 @@ Runs `compilation-mode-hook' with `run-mode-hooks' 
(which see).
 
 (autoload 'compilation-shell-minor-mode "compile" "\
 Toggle Compilation Shell minor mode.
-With a prefix argument ARG, enable Compilation Shell minor mode
-if ARG is positive, and disable it otherwise.  If called from
-Lisp, enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Compilation-Shell minor mode if ARG is 
positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Compilation Shell minor mode is enabled, all the
 error-parsing commands of the Compilation major mode are
@@ -5359,9 +5399,11 @@ See `compilation-mode'.
 
 (autoload 'compilation-minor-mode "compile" "\
 Toggle Compilation minor mode.
-With a prefix argument ARG, enable Compilation minor mode if ARG
-is positive, and disable it otherwise.  If called from Lisp,
-enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Compilation minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Compilation minor mode is enabled, all the error-parsing
 commands of Compilation major mode are available.  See
@@ -5394,9 +5436,11 @@ or call the function `dynamic-completion-mode'.")
 
 (autoload 'dynamic-completion-mode "completion" "\
 Toggle dynamic word-completion on or off.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Dynamic-Completion mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -5959,9 +6003,11 @@ or call the function `cua-mode'.")
 
 (autoload 'cua-mode "cua-base" "\
 Toggle Common User Access style editing (CUA mode).
-With a prefix argument ARG, enable CUA mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Cua mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 CUA mode is a global minor mode.  When enabled, typed text
 replaces the active selection, and you can use C-z, C-x, C-c, and
@@ -6006,6 +6052,11 @@ Enable CUA selection mode without the C-z/C-x/C-c/C-v 
bindings.
 Toggle the region as rectangular.
 Activates the region if needed.  Only lasts until the region is deactivated.
 
+If called interactively, enable Cua-Rectangle-Mark mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"cua-rect" '("cua-")))
@@ -6021,6 +6072,11 @@ Activates the region if needed.  Only lasts until the 
region is deactivated.
 (autoload 'cursor-intangible-mode "cursor-sensor" "\
 Keep cursor outside of any `cursor-intangible' text property.
 
+If called interactively, enable Cursor-Intangible mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (autoload 'cursor-sensor-mode "cursor-sensor" "\
@@ -6031,6 +6087,11 @@ where WINDOW is the affected window, OLDPOS is the last 
known position of
 the cursor and DIR can be `entered' or `left' depending on whether the cursor
 is entering the area covered by the text-property property or leaving it.
 
+If called interactively, enable Cursor-Sensor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"cursor-sensor" '("cursor-sensor-")))
@@ -6421,16 +6482,17 @@ Mode used for cvs status output.
 (autoload 'cwarn-mode "cwarn" "\
 Minor mode that highlights suspicious C and C++ constructions.
 
+If called interactively, enable Cwarn mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 Suspicious constructs are highlighted using `font-lock-warning-face'.
 
 Note, in addition to enabling this minor mode, the major mode must
 be included in the variable `cwarn-configuration'.  By default C and
 C++ modes are included.
 
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
-
 \(fn &optional ARG)" t nil)
 
 (define-obsolete-function-alias 'turn-on-cwarn-mode 'cwarn-mode "24.1")
@@ -6849,12 +6911,11 @@ or call the function `delete-selection-mode'.")
 
 (autoload 'delete-selection-mode "delsel" "\
 Toggle Delete Selection mode.
-Interactively, with a prefix argument, enable
-Delete Selection mode if the prefix argument is positive,
-and disable it otherwise.  If called from Lisp, toggle
-the mode if ARG is `toggle', disable the mode if ARG is
-a non-positive integer, and enable the mode otherwise
-\(including if ARG is omitted or nil or a positive integer).
+
+If called interactively, enable Delete-Selection mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Delete Selection mode is enabled, typed text replaces the selection
 if the selection is active.  Otherwise, typed text is just inserted at
@@ -7006,9 +7067,11 @@ or call the function `desktop-save-mode'.")
 
 (autoload 'desktop-save-mode "desktop" "\
 Toggle desktop saving (Desktop Save mode).
-With a prefix argument ARG, enable Desktop Save mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode if ARG
-is omitted or nil.
+
+If called interactively, enable Desktop-Save mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Desktop Save mode is enabled, the state of Emacs is saved from
 one session to another.  In particular, Emacs will save the desktop when
@@ -7371,9 +7434,11 @@ a diff with \\[diff-reverse-direction].
 
 (autoload 'diff-minor-mode "diff-mode" "\
 Toggle Diff minor mode.
-With a prefix argument ARG, enable Diff minor mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Diff minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \\{diff-minor-mode-map}
 
@@ -7549,9 +7614,11 @@ Keybindings:
 
 (autoload 'dirtrack-mode "dirtrack" "\
 Toggle directory tracking in shell buffers (Dirtrack mode).
-With a prefix argument ARG, enable Dirtrack mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Dirtrack mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 This method requires that your shell prompt contain the current
 working directory at all times, and that you set the variable
@@ -7723,6 +7790,11 @@ in `.emacs'.
 Toggle display of line numbers in the buffer.
 This uses `display-line-numbers' internally.
 
+If called interactively, enable Display-Line-Numbers mode if ARG is positive, 
and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 To change the type of line numbers displayed by default,
 customize `display-line-numbers-type'.  To change the type while
 the mode is on, set `display-line-numbers' directly.
@@ -7856,9 +7928,11 @@ to the next best mode.
 
 (autoload 'doc-view-minor-mode "doc-view" "\
 Toggle displaying buffer via Doc View (Doc View minor mode).
-With a prefix argument ARG, enable Doc View minor mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Doc-View minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 See the command `doc-view-mode' for more information on this mode.
 
@@ -7918,9 +7992,11 @@ Switch to *doctor* buffer and start giving psychotherapy.
 
 (autoload 'double-mode "double" "\
 Toggle special insertion on double keypresses (Double mode).
-With a prefix argument ARG, enable Double mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Double mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Double mode is enabled, some keys will insert different
 strings when pressed twice.  See `double-map' for details.
@@ -7975,7 +8051,9 @@ non-positive integer, and enables the mode otherwise 
(including
 if the argument is omitted or nil or a positive integer).
 
 If DOC is nil, give the mode command a basic doc-string
-documenting what its argument does.
+documenting what its argument does.  If the word \"ARG\" does not
+appear in DOC, a paragraph is added to DOC explaining
+usage of the mode argument.
 
 Optional INIT-VALUE is the initial value of the mode's variable.
 Optional LIGHTER is displayed in the mode line when the mode is on.
@@ -8785,9 +8863,11 @@ or call the function `global-ede-mode'.")
 
 (autoload 'global-ede-mode "ede" "\
 Toggle global EDE (Emacs Development Environment) mode.
-With a prefix argument ARG, enable global EDE mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Global Ede mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 This global minor mode enables `ede-minor-mode' in all buffers in
 an EDE controlled project.
@@ -9797,9 +9877,11 @@ or call the function `electric-pair-mode'.")
 
 (autoload 'electric-pair-mode "elec-pair" "\
 Toggle automatic parens pairing (Electric Pair mode).
-With a prefix argument ARG, enable Electric Pair mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Electric-Pair mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Electric Pair mode is a global minor mode.  When enabled, typing
 an open parenthesis automatically inserts the corresponding
@@ -9814,6 +9896,11 @@ To toggle the mode in a single buffer, use 
`electric-pair-local-mode'.
 (autoload 'electric-pair-local-mode "elec-pair" "\
 Toggle `electric-pair-mode' only in this buffer.
 
+If called interactively, enable Electric-Pair-Local mode if ARG is positive, 
and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"elec-pair" '("electric-pair-")))
@@ -10053,9 +10140,7 @@ displayed.
 (autoload 'emacs-lock-mode "emacs-lock" "\
 Toggle Emacs Lock mode in the current buffer.
 If called with a plain prefix argument, ask for the locking mode
-to be used.  With any other prefix ARG, turn mode on if ARG is
-positive, off otherwise.  If called from Lisp, enable the mode if
-ARG is omitted or nil.
+to be used.
 
 Initially, if the user does not pass an explicit locking mode, it
 defaults to `emacs-lock-default-locking-mode' (which see);
@@ -10070,6 +10155,9 @@ When called from Elisp code, ARG can be any locking 
mode:
 
 Other values are interpreted as usual.
 
+See also `emacs-lock-unlockable-modes', which exempts buffers under
+some major modes from being locked under some circumstances.
+
 \(fn &optional ARG)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"emacs-lock" '("emacs-lock-" "toggle-emacs-lock")))
@@ -10161,9 +10249,10 @@ Minor mode for editing text/enriched files.
 These are files with embedded formatting information in the MIME standard
 text/enriched format.
 
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+If called interactively, enable Enriched mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Turning the mode on or off runs `enriched-mode-hook'.
 
@@ -10432,9 +10521,11 @@ Encrypt marked files.
 
 (autoload 'epa-mail-mode "epa-mail" "\
 A minor-mode for composing encrypted/clearsigned mails.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable epa-mail mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -10497,9 +10588,11 @@ or call the function `epa-global-mail-mode'.")
 
 (autoload 'epa-global-mail-mode "epa-mail" "\
 Minor mode to hook EasyPG into Mail mode.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Epa-Global-Mail mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -10545,8 +10638,13 @@ Return a list of internal configuration parameters of 
`epg-gpg-program'.
 
 (autoload 'epg-check-configuration "epg-config" "\
 Verify that a sufficient version of GnuPG is installed.
+CONFIG should be a `epg-configuration' object (a plist).
+REQ-VERSIONS should be a list with elements of the form (MIN
+. MAX) where MIN and MAX are version strings indicating a
+semi-open range of acceptable versions.  REQ-VERSIONS may also be
+a single minimum version string.
 
-\(fn CONFIG &optional MINIMUM-VERSION)" nil nil)
+\(fn CONFIG &optional REQ-VERSIONS)" nil nil)
 
 (autoload 'epg-expand-group "epg-config" "\
 Look at CONFIG and try to expand GROUP.
@@ -12087,10 +12185,14 @@ a top-level keymap, `text-scale-increase' or
 
 (autoload 'buffer-face-mode "face-remap" "\
 Minor mode for a buffer-specific default face.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.  When enabled, the face specified by the
-variable `buffer-face-mode-face' is used to display the buffer text.
+
+If called interactively, enable Buffer-Face mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
+When enabled, the face specified by the variable
+`buffer-face-mode-face' is used to display the buffer text.
 
 \(fn &optional ARG)" t nil)
 
@@ -12972,9 +13074,11 @@ region is invalid.
 
 (autoload 'flymake-mode "flymake" "\
 Toggle Flymake mode on or off.
-With a prefix argument ARG, enable Flymake mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
+
+If called interactively, enable Flymake mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Flymake is an Emacs minor mode for on-the-fly syntax checking.
 Flymake collects diagnostic information from multiple sources,
@@ -13060,9 +13164,11 @@ Turn on `flyspell-mode' for comments and strings.
 
 (autoload 'flyspell-mode "flyspell" "\
 Toggle on-the-fly spell checking (Flyspell mode).
-With a prefix argument ARG, enable Flyspell mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Flyspell mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Flyspell mode is a buffer-local minor mode.  When enabled, it
 spawns a single Ispell process and checks each word.  The default
@@ -13110,6 +13216,9 @@ Turn Flyspell mode off.
 (autoload 'flyspell-region "flyspell" "\
 Flyspell text between BEG and END.
 
+Make sure `flyspell-mode' is turned on if you want the highlight
+of a misspelled word removed when you've corrected it.
+
 \(fn BEG END)" t nil)
 
 (autoload 'flyspell-buffer "flyspell" "\
@@ -13144,9 +13253,11 @@ Turn off Follow mode.  Please see the function 
`follow-mode'.
 
 (autoload 'follow-mode "follow" "\
 Toggle Follow mode.
-With a prefix argument ARG, enable Follow mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Follow mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Follow mode is a minor mode that combines windows into one tall
 virtual window.  This is accomplished by two main techniques:
@@ -13267,9 +13378,11 @@ selected if the original window is the first one in 
the frame.
 
 (autoload 'footnote-mode "footnote" "\
 Toggle Footnote mode.
-With a prefix argument ARG, enable Footnote mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Footnote mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Footnote mode is a buffer-local minor mode.  If enabled, it
 provides footnote support for `message-mode'.  To get started,
@@ -13691,6 +13804,11 @@ being transferred.  This list may grow up to a size of
 `gdb-debug-log-max' after which the oldest element (at the end of
 the list) is deleted every time a new one is added (at the front).
 
+If called interactively, enable Gdb-Enable-Debug mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (autoload 'gdb "gdb-mi" "\
@@ -13859,10 +13977,14 @@ regular expression that can be used as an element of
 
 (autoload 'glasses-mode "glasses" "\
 Minor mode for making identifiers likeThis readable.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.  When this mode is active, it tries to
-add virtual separators (like underscores) at places they belong to.
+
+If called interactively, enable Glasses mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
+When this mode is active, it tries to add virtual
+separators (like underscores) at places they belong to.
 
 \(fn &optional ARG)" t nil)
 
@@ -14469,6 +14591,11 @@ If FORCE is non-nil, replace the old ones.
 (autoload 'gnus-mailing-list-mode "gnus-ml" "\
 Minor mode for providing mailing-list commands.
 
+If called interactively, enable Gnus-Mailing-List mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \\{gnus-mailing-list-mode-map}
 
 \(fn &optional ARG)" t nil)
@@ -14889,7 +15016,14 @@ number with fewer than this number of bits, the 
handshake is
 rejected.  (The smaller the prime number, the less secure the
 key exchange is against man-in-the-middle attacks.)
 
-A value of nil says to use the default GnuTLS value.")
+A value of nil says to use the default GnuTLS value.
+
+The default value of this variable is such that virtually any
+connection can be established, whether this connection can be
+considered cryptographically \"safe\" or not.  However, Emacs
+network security is handled at a higher level via
+`open-network-stream' and the Network Security Manager.  See Info
+node `(emacs) Network Security'.")
 
 (custom-autoload 'gnutls-min-prime-bits "gnutls" t)
 
@@ -14951,15 +15085,22 @@ Also fontifies the buffer appropriately (see 
`goto-address-fontify-p' and
 
 (autoload 'goto-address-mode "goto-addr" "\
 Minor mode to buttonize URLs and e-mail addresses in the current buffer.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Goto-Address mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
 (autoload 'goto-address-prog-mode "goto-addr" "\
 Like `goto-address-mode', but only for comments and strings.
 
+If called interactively, enable Goto-Address-Prog mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"goto-addr" '("goto-address-")))
@@ -15017,7 +15158,7 @@ List of hook functions run by `grep-process-setup' (see 
`run-hooks').")
 
 (custom-autoload 'grep-setup-hook "grep" t)
 
-(defconst grep-regexp-alist `((,(concat "^\\(?:" 
"\\(?1:[^\0\n]+\\)\\(?3:\0\\)\\(?2:[0-9]+\\):" "\\|" 
"\\(?1:[^\n:]+?[^\n/:]\\):[\11 ]*\\(?2:[1-9][0-9]*\\)[\11 ]*:" "\\)") 1 2 
(,(lambda nil (when grep-highlight-matches (let* ((beg (match-end 0)) (end 
(save-excursion (goto-char beg) (line-end-position))) (mbeg (text-property-any 
beg end 'font-lock-face 'grep-match-face))) (when mbeg (- mbeg beg))))) \, 
(lambda nil (when grep-highlight-matches (let* ((beg (match-end 0)) (end 
(save-excursio [...]
+(defconst grep-regexp-alist `((,(concat "^\\(?:" 
"\\(?1:[^\0\n]+\\)\\(?3:\0\\)\\(?2:[0-9]+\\):" "\\|" "\\(?1:" 
"\\(?:[a-zA-Z]:\\)?" "[^\n:]+?[^\n/:]\\):[\11 ]*\\(?2:[1-9][0-9]*\\)[\11 ]*:" 
"\\)") 1 2 (,(lambda nil (when grep-highlight-matches (let* ((beg (match-end 
0)) (end (save-excursion (goto-char beg) (line-end-position))) (mbeg 
(text-property-any beg end 'font-lock-face 'grep-match-face))) (when mbeg (- 
mbeg beg))))) \, (lambda nil (when grep-highlight-matches (let* ((beg 
(match-end [...]
 Regexp used to match grep hits.
 See `compilation-error-regexp-alist' for format details.")
 
@@ -15259,9 +15400,11 @@ or call the function `gud-tooltip-mode'.")
 
 (autoload 'gud-tooltip-mode "gud" "\
 Toggle the display of GUD tooltips.
-With a prefix argument ARG, enable the feature if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-it if ARG is omitted or nil.
+
+If called interactively, enable Gud-Tooltip mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -15944,9 +16087,11 @@ This discards the buffer's undo information.
 
 (autoload 'hi-lock-mode "hi-lock" "\
 Toggle selective highlighting of patterns (Hi Lock mode).
-With a prefix argument ARG, enable Hi Lock mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Hi-Lock mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Hi Lock mode is automatically enabled when you invoke any of the
 highlighting commands listed below, such as \\[highlight-regexp].
@@ -16114,9 +16259,11 @@ be found in variable `hi-lock-interactive-patterns'.
 
 (autoload 'hide-ifdef-mode "hideif" "\
 Toggle features to hide/show #ifdef blocks (Hide-Ifdef mode).
-With a prefix argument ARG, enable Hide-Ifdef mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Hide-Ifdef mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Hide-Ifdef mode is a buffer-local minor mode for use with C and
 C-like major modes.  When enabled, code within #ifdef constructs
@@ -16191,9 +16338,11 @@ whitespace.  Case does not matter.")
 
 (autoload 'hs-minor-mode "hideshow" "\
 Minor mode to selectively hide/show code and comment blocks.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Hs minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When hideshow minor mode is on, the menu bar is augmented with hideshow
 commands and the hideshow commands are enabled.
@@ -16227,9 +16376,11 @@ Unconditionally turn off `hs-minor-mode'.
 
 (autoload 'highlight-changes-mode "hilit-chg" "\
 Toggle highlighting changes in this buffer (Highlight Changes mode).
-With a prefix argument ARG, enable Highlight Changes mode if ARG
-is positive, and disable it otherwise.  If called from Lisp,
-enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Highlight-Changes mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Highlight Changes is enabled, changes are marked with a text
 property.  Normally they are displayed in a distinctive face, but
@@ -16250,9 +16401,11 @@ buffer with the contents of a file
 
 (autoload 'highlight-changes-visible-mode "hilit-chg" "\
 Toggle visibility of highlighting due to Highlight Changes mode.
-With a prefix argument ARG, enable Highlight Changes Visible mode
-if ARG is positive, and disable it otherwise.  If called from
-Lisp, enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Highlight-Changes-Visible mode if ARG is 
positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Highlight Changes Visible mode only has an effect when Highlight
 Changes mode is on.  When enabled, the changed text is displayed
@@ -16395,9 +16548,11 @@ argument VERBOSE non-nil makes the function verbose.
 
 (autoload 'hl-line-mode "hl-line" "\
 Toggle highlighting of the current line (Hl-Line mode).
-With a prefix argument ARG, enable Hl-Line mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Hl-Line mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Hl-Line mode is a buffer-local minor mode.  If
 `hl-line-sticky-flag' is non-nil, Hl-Line mode highlights the
@@ -16425,9 +16580,11 @@ or call the function `global-hl-line-mode'.")
 
 (autoload 'global-hl-line-mode "hl-line" "\
 Toggle line highlighting in all buffers (Global Hl-Line mode).
-With a prefix argument ARG, enable Global Hl-Line mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Global Hl-Line mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 If `global-hl-line-sticky-flag' is non-nil, Global Hl-Line mode
 highlights the line about the current buffer's point in all live
@@ -16841,9 +16998,11 @@ or call the function `icomplete-mode'.")
 
 (autoload 'icomplete-mode "icomplete" "\
 Toggle incremental minibuffer completion (Icomplete mode).
-With a prefix argument ARG, enable Icomplete mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Icomplete mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When this global minor mode is enabled, typing in the minibuffer
 continuously displays a list of possible completions that match
@@ -17392,10 +17551,11 @@ DEF, if non-nil, is the default value.
 
 (autoload 'ielm "ielm" "\
 Interactively evaluate Emacs Lisp expressions.
-Switches to the buffer `*ielm*', or creates it if it does not exist.
+Switches to the buffer named BUF-NAME if provided (`*ielm*' by default),
+or creates it if it does not exist.
 See `inferior-emacs-lisp-mode' for details.
 
-\(fn)" t nil)
+\(fn &optional BUF-NAME)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ielm" '("ielm-" "inferior-emacs-lisp-mode")))
 
@@ -17415,9 +17575,12 @@ See `inferior-emacs-lisp-mode' for details.
 
 (autoload 'iimage-mode "iimage" "\
 Toggle Iimage mode on or off.
-With a prefix argument ARG, enable Iimage mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
+
+If called interactively, enable Iimage mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \\{iimage-mode-map}
 
 \(fn &optional ARG)" t nil)
@@ -17710,6 +17873,11 @@ Setup easy-to-use keybindings for the commands to be 
used in dired mode.
 Note that n, p and <down> and <up> will be hijacked and bound to
 `image-dired-dired-x-line'.
 
+If called interactively, enable Image-Dired minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (define-obsolete-function-alias 'image-dired-setup-dired-keybindings 
'image-dired-minor-mode "26.1")
@@ -17813,9 +17981,11 @@ or call the function `auto-image-file-mode'.")
 
 (autoload 'auto-image-file-mode "image-file" "\
 Toggle visiting of image files as images (Auto Image File mode).
-With a prefix argument ARG, enable Auto Image File mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Auto-Image-File mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 An image file is one whose name has an extension in
 `image-file-name-extensions', or matches a regexp in
@@ -17842,9 +18012,11 @@ Key bindings:
 
 (autoload 'image-minor-mode "image-mode" "\
 Toggle Image minor mode in this buffer.
-With a prefix argument ARG, enable Image minor mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Image minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Image minor mode provides the key \\<image-mode-map>\\[image-toggle-display],
 to switch back to `image-mode' and display an image file as the
@@ -17907,9 +18079,9 @@ string (which specifies the title of a submenu into 
which the
 matches are put).
 REGEXP is a regular expression matching a definition construct
 which is to be displayed in the menu.  REGEXP may also be a
-function, called without arguments.  It is expected to search
-backwards.  It must return true and set `match-data' if it finds
-another element.
+function of no arguments.  If REGEXP is a function, it is
+expected to search backwards, return non-nil if it finds a
+definition construct, and set `match-data' for that construct.
 INDEX is an integer specifying which subexpression of REGEXP
 matches the definition's name; this subexpression is displayed as
 the menu item.
@@ -18824,9 +18996,11 @@ available on the net.
 
 (autoload 'ispell-minor-mode "ispell" "\
 Toggle last-word spell checking (Ispell minor mode).
-With a prefix argument ARG, enable Ispell minor mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable ISpell minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Ispell minor mode is a buffer-local minor mode.  When enabled,
 typing SPC or RET warns you if the previous word is incorrectly
@@ -19510,9 +19684,11 @@ generations (this defaults to 1).
 
 (autoload 'linum-mode "linum" "\
 Toggle display of line numbers in the left margin (Linum mode).
-With a prefix argument ARG, enable Linum mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Linum mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Linum mode is a buffer-local minor mode.
 
@@ -20085,9 +20261,11 @@ or call the function `mail-abbrevs-mode'.")
 
 (autoload 'mail-abbrevs-mode "mailabbrev" "\
 Toggle abbrev expansion of mail aliases (Mail Abbrevs mode).
-With a prefix argument ARG, enable Mail Abbrevs mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Mail-Abbrevs mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Mail Abbrevs mode is a global minor mode.  When enabled,
 abbrev-like expansion is performed when editing certain mail
@@ -20431,9 +20609,11 @@ Default bookmark handler for Man buffers.
 
 (autoload 'master-mode "master" "\
 Toggle Master mode.
-With a prefix argument ARG, enable Master mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Master mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Master mode is enabled, you can scroll the slave buffer
 using the following commands:
@@ -20465,9 +20645,11 @@ or call the function 
`minibuffer-depth-indicate-mode'.")
 
 (autoload 'minibuffer-depth-indicate-mode "mb-depth" "\
 Toggle Minibuffer Depth Indication mode.
-With a prefix argument ARG, enable Minibuffer Depth Indication
-mode if ARG is positive, and disable it otherwise.  If called
-from Lisp, enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Minibuffer-Depth-Indicate mode if ARG is 
positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Minibuffer Depth Indication mode is a global minor mode.  When
 enabled, any recursive use of the minibuffer will show the
@@ -21095,6 +21277,11 @@ or call the function `midnight-mode'.")
 (autoload 'midnight-mode "midnight" "\
 Non-nil means run `midnight-hook' at midnight.
 
+If called interactively, enable Midnight mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (autoload 'clean-buffer-list "midnight" "\
@@ -21137,9 +21324,11 @@ or call the function 
`minibuffer-electric-default-mode'.")
 
 (autoload 'minibuffer-electric-default-mode "minibuf-eldef" "\
 Toggle Minibuffer Electric Default mode.
-With a prefix argument ARG, enable Minibuffer Electric Default
-mode if ARG is positive, and disable it otherwise.  If called
-from Lisp, enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Minibuffer-Electric-Default mode if ARG is 
positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Minibuffer Electric Default mode is a global minor mode.  When
 enabled, minibuffer prompts that show a default value only show
@@ -21722,9 +21911,11 @@ or call the function `msb-mode'.")
 
 (autoload 'msb-mode "msb" "\
 Toggle Msb mode.
-With a prefix argument ARG, enable Msb mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Msb mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 This mode overrides the binding(s) of `mouse-buffer-menu' to provide a
 different buffer menu using the function `msb'.
@@ -23390,6 +23581,11 @@ modes.  The following keys behave as if Org mode were 
active, if
 the cursor is on a headline, or on a plain list item (both as
 defined by Org mode).
 
+If called interactively, enable OrgStruct mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (autoload 'turn-on-orgstruct "org" "\
@@ -24302,9 +24498,11 @@ Turning on outline mode calls the value of 
`text-mode-hook' and then of
 
 (autoload 'outline-minor-mode "outline" "\
 Toggle Outline minor mode.
-With a prefix argument ARG, enable Outline minor mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Outline minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 See the command `outline-mode' for more information on this mode.
 
@@ -24579,9 +24777,11 @@ or call the function `show-paren-mode'.")
 
 (autoload 'show-paren-mode "paren" "\
 Toggle visualization of matching parens (Show Paren mode).
-With a prefix argument ARG, enable Show Paren mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Show-Paren mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Show Paren mode is a global minor mode.  When enabled, any
 matching parenthesis is highlighted in `show-paren-style' after
@@ -25300,9 +25500,11 @@ or call the function `pixel-scroll-mode'.")
 
 (autoload 'pixel-scroll-mode "pixel-scroll" "\
 A minor mode to scroll text pixel-by-pixel.
-With a prefix argument ARG, enable Pixel Scroll mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable Pixel Scroll mode
-if ARG is omitted or nil.
+
+If called interactively, enable Pixel-Scroll mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -26959,9 +27161,11 @@ or call the function `rcirc-track-minor-mode'.")
 
 (autoload 'rcirc-track-minor-mode "rcirc" "\
 Global minor mode for tracking activity in rcirc buffers.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Rcirc-Track minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -27005,9 +27209,11 @@ or call the function `recentf-mode'.")
 
 (autoload 'recentf-mode "recentf" "\
 Toggle \"Open Recent\" menu (Recentf mode).
-With a prefix argument ARG, enable Recentf mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-Recentf mode if ARG is omitted or nil.
+
+If called interactively, enable Recentf mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Recentf mode is enabled, a \"Open Recent\" submenu is
 displayed in the \"File\" menu, containing a list of files that
@@ -27157,6 +27363,12 @@ with a prefix argument, prompt for START-AT and FORMAT.
 
 (autoload 'rectangle-mark-mode "rect" "\
 Toggle the region as rectangular.
+
+If called interactively, enable Rectangle-Mark mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 Activates the region if needed.  Only lasts until the region is deactivated.
 
 \(fn &optional ARG)" t nil)
@@ -27184,9 +27396,11 @@ Activates the region if needed.  Only lasts until the 
region is deactivated.
 
 (autoload 'refill-mode "refill" "\
 Toggle automatic refilling (Refill mode).
-With a prefix argument ARG, enable Refill mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Refill mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Refill mode is a buffer-local minor mode.  When enabled, the
 current paragraph is refilled as you edit.  Self-inserting
@@ -27216,6 +27430,11 @@ Turn on RefTeX mode.
 (autoload 'reftex-mode "reftex" "\
 Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX.
 
+If called interactively, enable Reftex mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \\<reftex-mode-map>A Table of Contents of the entire (multifile) document with 
browsing
 capabilities is available with `\\[reftex-toc]'.
 
@@ -27560,9 +27779,11 @@ first comment line visible (if point is in a comment).
 
 (autoload 'reveal-mode "reveal" "\
 Toggle uncloaking of invisible text near point (Reveal mode).
-With a prefix argument ARG, enable Reveal mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-Reveal mode if ARG is omitted or nil.
+
+If called interactively, enable Reveal mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Reveal mode is a buffer-local minor mode.  When enabled, it
 reveals invisible text around point.
@@ -27583,9 +27804,10 @@ or call the function `global-reveal-mode'.")
 Toggle Reveal mode in all buffers (Global Reveal mode).
 Reveal mode renders invisible text around point visible again.
 
-With a prefix argument ARG, enable Global Reveal mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+If called interactively, enable Global Reveal mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -28303,9 +28525,11 @@ highlighting.
 
 (autoload 'rst-minor-mode "rst" "\
 Toggle ReST minor mode.
-With a prefix argument ARG, enable ReST minor mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Rst minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When ReST minor mode is enabled, the ReST mode keybindings
 are installed on top of the major mode bindings.  Use this
@@ -28352,9 +28576,11 @@ Use the command `ruler-mode' to change this variable.")
 
 (autoload 'ruler-mode "ruler-mode" "\
 Toggle display of ruler in header line (Ruler mode).
-With a prefix argument ARG, enable Ruler mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Ruler mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -28738,9 +28964,11 @@ or call the function `savehist-mode'.")
 
 (autoload 'savehist-mode "savehist" "\
 Toggle saving of minibuffer history (Savehist mode).
-With a prefix argument ARG, enable Savehist mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Savehist mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Savehist mode is enabled, minibuffer history is saved
 periodically and when exiting Emacs.  When Savehist mode is
@@ -28775,6 +29003,11 @@ Non-nil means automatically save place in each file.
 This means when you visit a file, point goes to the last place
 where it was when you previously visited the same file.
 
+If called interactively, enable Save-Place mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (autoload 'save-place-local-mode "saveplace" "\
@@ -28783,8 +29016,10 @@ If this mode is enabled, point is recorded when you 
kill the buffer
 or exit Emacs.  Visiting this file again will go to that position,
 even in a later Emacs session.
 
-If called with a prefix arg, the mode is enabled if and only if
-the argument is positive.
+If called interactively, enable Save-Place-Local mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 To save places automatically in all files, put this in your init
 file:
@@ -28875,9 +29110,11 @@ or call the function `scroll-all-mode'.")
 
 (autoload 'scroll-all-mode "scroll-all" "\
 Toggle shared scrolling in same-frame windows (Scroll-All mode).
-With a prefix argument ARG, enable Scroll-All mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Scroll-All mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Scroll-All mode is enabled, scrolling commands invoked in
 one window apply to all visible windows in the same frame.
@@ -28900,12 +29137,16 @@ one window apply to all visible windows in the same 
frame.
 
 (autoload 'scroll-lock-mode "scroll-lock" "\
 Buffer-local minor mode for pager-like scrolling.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.  When enabled, keys that normally move
-point by line or paragraph will scroll the buffer by the
-respective amount of lines instead and point will be kept
-vertically fixed relative to window boundaries during scrolling.
+
+If called interactively, enable Scroll-Lock mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
+When enabled, keys that normally move point by line or paragraph
+will scroll the buffer by the respective amount of lines instead
+and point will be kept vertically fixed relative to window
+boundaries during scrolling.
 
 \(fn &optional ARG)" t nil)
 
@@ -28964,9 +29205,11 @@ or call the function `semantic-mode'.")
 
 (autoload 'semantic-mode "semantic" "\
 Toggle parser features (Semantic mode).
-With a prefix argument ARG, enable Semantic mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-Semantic mode if ARG is omitted or nil.
+
+If called interactively, enable Semantic mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 In Semantic mode, Emacs parses the buffers you visit for their
 semantic content.  This information is used by a variety of
@@ -29925,9 +30168,11 @@ or call the function `server-mode'.")
 
 (autoload 'server-mode "server" "\
 Toggle Server mode.
-With a prefix argument ARG, enable Server mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-Server mode if ARG is omitted or nil.
+
+If called interactively, enable Server mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Server mode runs a process that accepts commands from the
 `emacsclient' program.  See Info node `Emacs server' and
@@ -30550,9 +30795,12 @@ buffer names.
 
 (autoload 'smerge-mode "smerge-mode" "\
 Minor mode to simplify editing output from the diff3 program.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Smerge mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \\{smerge-mode-map}
 
 \(fn &optional ARG)" t nil)
@@ -31865,9 +32113,11 @@ or call the function `strokes-mode'.")
 
 (autoload 'strokes-mode "strokes" "\
 Toggle Strokes mode, a global minor mode.
-With a prefix argument ARG, enable Strokes mode if ARG is
-positive, and disable it otherwise.  If called from Lisp,
-enable the mode if ARG is omitted or nil.
+
+If called interactively, enable Strokes mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \\<strokes-mode-map>
 Strokes are pictographic mouse gestures which invoke commands.
@@ -31934,9 +32184,11 @@ Studlify-case the current buffer.
 
 (autoload 'subword-mode "subword" "\
 Toggle subword movement and editing (Subword mode).
-With a prefix argument ARG, enable Subword mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Subword mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Subword mode is a buffer-local minor mode.  Enabling it changes
 the definition of a word so that word-based commands stop inside
@@ -31956,8 +32208,6 @@ called a `subword'.  Here are some examples:
 This mode changes the definition of a word so that word commands
 treat nomenclature boundaries as word boundaries.
 
-\\{subword-mode-map}
-
 \(fn &optional ARG)" t nil)
 
 (defvar global-subword-mode nil "\
@@ -31984,9 +32234,11 @@ See `subword-mode' for more information on Subword 
mode.
 
 (autoload 'superword-mode "subword" "\
 Toggle superword movement and editing (Superword mode).
-With a prefix argument ARG, enable Superword mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Superword mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Superword mode is a buffer-local minor mode.  Enabling it changes
 the definition of words such that symbols characters are treated
@@ -32081,9 +32333,11 @@ or call the function `gpm-mouse-mode'.")
 
 (autoload 'gpm-mouse-mode "t-mouse" "\
 Toggle mouse support in GNU/Linux consoles (GPM Mouse mode).
-With a prefix argument ARG, enable GPM Mouse mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Gpm-Mouse mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 This allows the use of the mouse when operating on a GNU/Linux console,
 in the same way as you can use the mouse under X11.
@@ -32481,6 +32735,11 @@ location is indicated by 
`table-word-continuation-char'.  This
 variable's value can be toggled by \\[table-fixed-width-mode] at
 run-time.
 
+If called interactively, enable Table-Fixed-Width mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 \(fn &optional ARG)" t nil)
 
 (autoload 'table-query-dimension "table" "\
@@ -33667,6 +33926,11 @@ This function is meant to be used as a 
`post-self-insert-hook'.
 (autoload 'tildify-mode "tildify" "\
 Adds electric behavior to space character.
 
+If called interactively, enable Tildify mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 When space is inserted into a buffer in a position where hard space is required
 instead (determined by `tildify-space-pattern' and `tildify-space-predicates'),
 that space character is replaced by a hard space specified by
@@ -33712,9 +33976,11 @@ or call the function `display-time-mode'.")
 
 (autoload 'display-time-mode "time" "\
 Toggle display of time, load level, and mail flag in mode lines.
-With a prefix argument ARG, enable Display Time mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-it if ARG is omitted or nil.
+
+If called interactively, enable Display-Time mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When Display Time mode is enabled, it updates every minute (you
 can control the number of seconds between updates by customizing
@@ -34571,6 +34837,11 @@ or call the function `type-break-mode'.")
 Enable or disable typing-break mode.
 This is a minor mode, but it is global to all buffers by default.
 
+If called interactively, enable Type-Break mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
+
 When this mode is enabled, the user is encouraged to take typing breaks at
 appropriate intervals; either after a specified amount of time or when the
 user has exceeded a keystroke threshold.  When the time arrives, the user
@@ -34579,9 +34850,6 @@ again in a short period of time.  The idea is to give 
the user enough time
 to find a good breaking point in his or her work, but be sufficiently
 annoying to discourage putting typing breaks off indefinitely.
 
-A negative prefix argument disables this mode.
-No argument or any non-negative argument enables it.
-
 The user may enable or disable this mode by setting the variable of the
 same name, though setting it in that way doesn't reschedule a break or
 reset the keystroke counter.
@@ -35105,9 +35373,11 @@ or call the function `url-handler-mode'.")
 
 (autoload 'url-handler-mode "url-handlers" "\
 Toggle using `url' library for URL filenames (URL Handler mode).
-With a prefix argument ARG, enable URL Handler mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Url-Handler mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -37252,9 +37522,11 @@ own View-like bindings.
 
 (autoload 'view-mode "view" "\
 Toggle View mode, a minor mode for viewing text but not editing it.
-With a prefix argument ARG, enable View mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable View mode
-if ARG is omitted or nil.
+
+If called interactively, enable View mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 When View mode is enabled, commands that do not change the buffer
 contents are available as usual.  Kill commands insert text in
@@ -37628,9 +37900,11 @@ or call the function `which-function-mode'.")
 
 (autoload 'which-function-mode "which-func" "\
 Toggle mode line display of current function (Which Function mode).
-With a prefix argument ARG, enable Which Function mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Which-Function mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Which Function mode is a global minor mode.  When enabled, the
 current function name is continuously displayed in the mode line,
@@ -37648,11 +37922,11 @@ in certain major modes.
 
 (autoload 'whitespace-mode "whitespace" "\
 Toggle whitespace visualization (Whitespace mode).
-With a prefix argument ARG, enable Whitespace mode if ARG is
-positive, and disable it otherwise.
 
-If called from Lisp, also enables the mode if ARG is omitted or nil,
-and toggles it if ARG is `toggle'.
+If called interactively, enable Whitespace mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 See also `whitespace-style', `whitespace-newline' and
 `whitespace-display-mappings'.
@@ -37661,11 +37935,11 @@ See also `whitespace-style', `whitespace-newline' and
 
 (autoload 'whitespace-newline-mode "whitespace" "\
 Toggle newline visualization (Whitespace Newline mode).
-With a prefix argument ARG, enable Whitespace Newline mode if ARG
-is positive, and disable it otherwise.
 
-If called from Lisp, also enables the mode if ARG is omitted or nil,
-and toggles it if ARG is `toggle'.
+If called interactively, enable Whitespace-Newline mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Use `whitespace-newline-mode' only for NEWLINE visualization
 exclusively.  For other visualizations, including NEWLINE
@@ -37688,11 +37962,11 @@ or call the function `global-whitespace-mode'.")
 
 (autoload 'global-whitespace-mode "whitespace" "\
 Toggle whitespace visualization globally (Global Whitespace mode).
-With a prefix argument ARG, enable Global Whitespace mode if ARG
-is positive, and disable it otherwise.
 
-If called from Lisp, also enables the mode if ARG is omitted or nil,
-and toggles it if ARG is `toggle'.
+If called interactively, enable Global Whitespace mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 See also `whitespace-style', `whitespace-newline' and
 `whitespace-display-mappings'.
@@ -37711,11 +37985,11 @@ or call the function 
`global-whitespace-newline-mode'.")
 
 (autoload 'global-whitespace-newline-mode "whitespace" "\
 Toggle global newline visualization (Global Whitespace Newline mode).
-With a prefix argument ARG, enable Global Whitespace Newline mode
-if ARG is positive, and disable it otherwise.
 
-If called from Lisp, also enables the mode if ARG is omitted or nil,
-and toggles it if ARG is `toggle'.
+If called interactively, enable Global Whitespace-Newline mode if ARG is 
positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Use `global-whitespace-newline-mode' only for NEWLINE
 visualization exclusively.  For other visualizations, including
@@ -38037,9 +38311,11 @@ Show widget browser for WIDGET in other window.
 
 (autoload 'widget-minor-mode "wid-browse" "\
 Minor mode for traversing widgets.
-With a prefix argument ARG, enable the mode if ARG is positive,
-and disable it otherwise.  If called from Lisp, enable the mode
-if ARG is omitted or nil.
+
+If called interactively, enable Widget minor mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 \(fn &optional ARG)" t nil)
 
@@ -38161,9 +38437,11 @@ or call the function `winner-mode'.")
 
 (autoload 'winner-mode "winner" "\
 Toggle Winner mode on or off.
-With a prefix argument ARG, enable Winner mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
+
+If called interactively, enable Winner mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Winner mode is a global minor mode that records the changes in
 the window configuration (i.e. how the frames are partitioned
@@ -38373,6 +38651,12 @@ With prefix argument, prompt for the identifier.
 
 \(fn IDENTIFIER)" t nil)
 
+(autoload 'xref-find-definitions-at-mouse "xref" "\
+Find the definition of identifier at or around mouse click.
+This command is intended to be bound to a mouse event.
+
+\(fn EVENT)" t nil)
+
 (autoload 'xref-find-apropos "xref" "\
 Find all meaningful symbols that match PATTERN.
 The argument has the same meaning as in `apropos'.
@@ -38425,9 +38709,11 @@ or call the function `xterm-mouse-mode'.")
 
 (autoload 'xterm-mouse-mode "xt-mouse" "\
 Toggle XTerm mouse mode.
-With a prefix argument ARG, enable XTerm mouse mode if ARG is
-positive, and disable it otherwise.  If called from Lisp, enable
-the mode if ARG is omitted or nil.
+
+If called interactively, enable Xterm-Mouse mode if ARG is positive, and
+disable it if ARG is zero or negative.  If called from Lisp,
+also enable the mode if ARG is omitted or nil, and toggle it
+if ARG is `toggle'; disable the mode otherwise.
 
 Turn it on to use Emacs mouse commands, and off to use xterm mouse commands.
 This works in terminal emulators compatible with xterm.  It only
diff --git a/lisp/mh-e/mh-comp.el b/lisp/mh-e/mh-comp.el
index 2b49fae..5c474b4 100644
--- a/lisp/mh-e/mh-comp.el
+++ b/lisp/mh-e/mh-comp.el
@@ -77,6 +77,14 @@ Default is \"components\".
 If not an absolute file name, the file is searched for first in the
 user's MH directory, then in the system MH lib directory.")
 
+(defvar mh-dist-formfile "distcomps"
+  "Name of file to be used as a skeleton for redistributing messages.
+
+Default is \"distcomps\".
+
+If not an absolute file name, the file is searched for first in the
+user's MH directory, then in the system MH lib directory.")
+
 (defvar mh-repl-formfile "replcomps"
   "Name of file to be used as a skeleton for replying to messages.
 
@@ -413,7 +421,7 @@ See also `mh-send'."
   (interactive (list (mh-get-msg-num t)))
   (let* ((from-folder mh-current-folder)
          (config (current-window-configuration))
-         (components-file (mh-bare-components))
+         (components-file (mh-bare-components mh-comp-formfile))
          (draft
           (cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
                  (pop-to-buffer (find-file-noselect (mh-msg-filename message))
@@ -649,15 +657,16 @@ Original message has headers FROM and SUBJECT."
   (format mh-forward-subject-format from subject))
 
 ;;;###mh-autoload
-(defun mh-redistribute (to cc &optional message)
+(defun mh-redistribute (to cc identity &optional message)
   "Redistribute a message.
 
 This command is similar in function to forwarding mail, but it
 does not allow you to edit the message, nor does it add your name
 to the \"From\" header field. It appears to the recipient as if
 the message had come from the original sender. When you run this
-command, you are prompted for the TO and CC recipients. The
-default MESSAGE is the current message.
+command, you are prompted for the TO and CC recipients. You are
+also prompted for the sending IDENTITY to use. The default
+MESSAGE is the current message.
 
 Also investigate the command \\[mh-edit-again] for another way to
 redistribute messages.
@@ -668,6 +677,9 @@ The hook `mh-annotate-msg-hook' is run after annotating the
 message and scan line."
   (interactive (list (mh-read-address "Redist-To: ")
                      (mh-read-address "Redist-Cc: ")
+                     (if mh-identity-list
+                         (mh-select-identity mh-identity-default)
+                       nil)
                      (mh-get-msg-num t)))
   (or message
       (setq message (mh-get-msg-num t)))
@@ -677,14 +689,51 @@ message and scan line."
                                 (if mh-redist-full-contents-flag
                                     (mh-msg-filename message)
                                   nil)
-                                nil)))
-      (mh-goto-header-end 0)
-      (insert "Resent-To: " to "\n")
-      (if (not (equal cc "")) (insert "Resent-cc: " cc "\n"))
-      (mh-clean-msg-header
-       (point-min)
-       "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Sender:\\|^Date:\\|^From:"
-       nil)
+                                nil))
+          (from (mh-identity-field identity "From"))
+          (fcc  (mh-identity-field identity "Fcc"))
+          (bcc  (mh-identity-field identity "Bcc"))
+          comp-fcc comp-to comp-cc comp-bcc)
+      (if mh-redist-full-contents-flag
+          (mh-clean-msg-header
+           (point-min)
+           "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Date:\\|^Resent-.*:"
+           nil))
+      ;; Read fields from the distcomps file and put them in our
+      ;; draft. For "To", "Cc", "Bcc", and "Fcc", multiple headers are
+      ;; combined into a single header with comma-separated entries.
+      ;; For "From", the first value wins, with the identity's "From"
+      ;; trumping anything in the distcomps file.
+      (let ((components-file (mh-bare-components mh-dist-formfile)))
+        (mh-mapc
+         (function
+          (lambda (header-field)
+            (let ((field (car header-field))
+                  (value (cdr header-field))
+                  (case-fold-search t))
+              (cond
+               ((string-match field "^Resent-Fcc$")
+                (setq comp-fcc value))
+               ((string-match field "^Resent-From$")
+                (or from
+                    (setq from value)))
+               ((string-match field "^Resent-To$")
+                (setq comp-to value))
+               ((string-match field "^Resent-Cc$")
+                (setq comp-cc value))
+               ((string-match field "^Resent-Bcc$")
+                (setq comp-bcc value))
+               ((string-match field "^Resent-.*$")
+                (mh-insert-fields field value))))))
+         (mh-components-to-list components-file))
+        (delete-file components-file))
+      (mh-insert-fields "Resent-To:" (mapconcat 'identity (list to comp-to) ", 
")
+                        "Resent-Cc:" (mapconcat 'identity (list cc comp-cc) ", 
")
+                        "Resent-Fcc:" (mapconcat 'identity (list fcc
+                                                                 comp-fcc) ", 
")
+                        "Resent-Bcc:" (mapconcat 'identity (list bcc
+                                                                 comp-bcc) ", 
")
+                        "Resent-From:" from)
       (save-buffer)
       (message "Redistributing...")
       (let ((env "mhdist=1"))
@@ -702,7 +751,8 @@ message and scan line."
         ;; Annotate...
         (mh-annotate-msg message folder mh-note-dist
                          "-component" "Resent:"
-                         "-text" (format "\"%s %s\"" to cc)))
+                         "-text" (format "\"To: %s Cc: %s From: %s\""
+                                         to cc from)))
       (kill-buffer draft)
       (message "Redistributing...done"))))
 
@@ -898,7 +948,7 @@ CONFIG is the window configuration before sending mail."
     (message "Composing a message...")
     (let ((draft (mh-read-draft
                   "message"
-                  (mh-bare-components)
+                  (mh-bare-components mh-comp-formfile)
                   t)))
       (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
       (goto-char (point-max))
@@ -908,23 +958,25 @@ CONFIG is the window configuration before sending mail."
       (mh-letter-mode-message)
       (mh-letter-adjust-point))))
 
-(defun mh-bare-components ()
-  "Generate a temporary, clean components file and return its path."
-  ;; Let comp(1) create the skeleton for us.  This is particularly
+(defun mh-bare-components (formfile)
+  "Generate a temporary, clean components file from FORMFILE.
+Return the path to the temporary file."
+  ;; Let comp(1) create the skeleton for us. This is particularly
   ;; important with nmh-1.5, because its default "components" needs
-  ;; some processing before it can be used.  Unfortunately, comp(1)
-  ;; doesn't have a -build option.  So, to avoid the possibility of
-  ;; clobbering an existing draft, create a temporary directory and
-  ;; use it as the drafts folder.  Then copy the skeleton to a regular
-  ;; temp file, and return the regular temp file.
+  ;; some processing before it can be used. Unfortunately, comp(1)
+  ;; didn't have a -build option until later versions of nmh. So, to
+  ;; avoid the possibility of clobbering an existing draft, create
+  ;; a temporary directory and use it as the drafts folder. Then
+  ;; copy the skeleton to a regular temp file, and return the
+  ;; regular temp file.
   (let (new
         (temp-folder (make-temp-file
                       (concat mh-user-path "draftfolder.") t)))
     (mh-exec-cmd "comp" "-nowhatnowproc"
                  "-draftfolder" (format "+%s"
                                         (file-name-nondirectory temp-folder))
-                 (if (stringp mh-comp-formfile)
-                     (list "-form" mh-comp-formfile)))
+                 (if (stringp formfile)
+                     (list "-form" formfile)))
     (setq new (make-temp-file "comp."))
     (rename-file (concat temp-folder "/" "1") new t)
     ;; The temp folder could contain various metadata files.  Rather
diff --git a/lisp/mh-e/mh-funcs.el b/lisp/mh-e/mh-funcs.el
index 661d0ec..3574f8c 100644
--- a/lisp/mh-e/mh-funcs.el
+++ b/lisp/mh-e/mh-funcs.el
@@ -357,6 +357,8 @@ Arguments are IGNORED (for `revert-buffer')."
              (yes-or-no-p "Undo all commands in folder? "))
          (setq mh-delete-list nil
                mh-refile-list nil
+               mh-blacklist nil
+               mh-whitelist nil
                mh-seq-list nil
                mh-next-direction 'forward)
          (with-mh-folder-updating (nil)
diff --git a/lisp/mh-e/mh-identity.el b/lisp/mh-e/mh-identity.el
index fd7c2b8..a1eb22f 100644
--- a/lisp/mh-e/mh-identity.el
+++ b/lisp/mh-e/mh-identity.el
@@ -132,6 +132,33 @@ valid header field."
       'mh-identity-handler-default))
 
 ;;;###mh-autoload
+(defun mh-select-identity (default)
+  "Prompt for and return an identity.
+If DEFAULT is non-nil, it will be used if the user doesn't enter a
+different identity.
+
+See `mh-identity-list'."
+  (let (identity)
+    (setq identity
+          (completing-read
+           "Identity: "
+           (cons '("None")
+                 (mapcar 'list (mapcar 'car mh-identity-list)))
+           nil t default nil default))
+    (if (eq identity "None")
+        nil
+      identity)))
+
+;;;###mh-autoload
+(defun mh-identity-field (identity field)
+  "Return the specified FIELD of the given IDENTITY.
+
+See `mh-identity-list'."
+  (let* ((pers-list (cadr (assoc identity mh-identity-list)))
+         (value (cdr (assoc field pers-list))))
+    value))
+
+;;;###mh-autoload
 (defun mh-insert-identity (identity &optional maybe-insert)
   "Insert fields specified by given IDENTITY.
 
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 1f40339..84af410 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -49,9 +49,9 @@
 
 ;; The user option `tramp-gvfs-methods' contains the list of supported
 ;; connection methods.  Per default, these are "afp", "dav", "davs",
-;; "gdrive", "owncloud" and "sftp".
+;; "gdrive", "nextcloud" and "sftp".
 
-;; "gdrive" and "owncloud" connection methods require a respective
+;; "gdrive" and "nextcloud" connection methods require a respective
 ;; account in GNOME Online Accounts, with enabled "Files" service.
 
 ;; Other possible connection methods are "ftp", "http", "https" and
@@ -121,7 +121,7 @@
 
 ;;;###tramp-autoload
 (defcustom tramp-gvfs-methods
-  '("afp" "dav" "davs" "gdrive" "owncloud" "sftp")
+  '("afp" "dav" "davs" "gdrive" "nextcloud" "sftp")
   "List of methods for remote files, accessed with GVFS."
   :group 'tramp
   :version "27.1"
@@ -132,11 +132,11 @@
                         (const "gdrive")
                         (const "http")
                         (const "https")
-                        (const "owncloud")
+                        (const "nextcloud")
                         (const "sftp")
                         (const "smb"))))
 
-(defconst tramp-goa-methods '("gdrive" "owncloud")
+(defconst tramp-goa-methods '("gdrive" "nextcloud")
   "List of methods which require registration at GNOME Online Accounts.")
 
 ;; Remove GNOME Online Accounts methods if not supported.
@@ -511,11 +511,11 @@ It has been changed in GVFS 1.14.")
          ":[[:blank:]]+\\(.*\\)$")
   "Regexp to parse GVFS file system attributes with `gvfs-info'.")
 
-(defconst tramp-gvfs-owncloud-default-prefix "/remote.php/webdav"
+(defconst tramp-gvfs-nextcloud-default-prefix "/remote.php/webdav"
   "Default prefix for owncloud / nextcloud methods.")
 
-(defconst tramp-gvfs-owncloud-default-prefix-regexp
-  (concat (regexp-quote tramp-gvfs-owncloud-default-prefix) "$")
+(defconst tramp-gvfs-nextcloud-default-prefix-regexp
+  (concat (regexp-quote tramp-gvfs-nextcloud-default-prefix) "$")
   "Regexp of default prefix for owncloud / nextcloud methods.")
 
 
@@ -1380,7 +1380,7 @@ file-notify events."
          (with-parsed-tramp-file-name filename nil
            (when (string-equal "gdrive" method)
              (setq method "google-drive"))
-           (when (string-equal "owncloud" method)
+           (when (string-equal "nextcloud" method)
              (setq method "davs"
                    localname
                    (concat (tramp-gvfs-get-remote-prefix v) localname)))
@@ -1543,8 +1543,8 @@ file-notify events."
          (setq method "davs"))
        (when (and (string-equal "davs" method)
                   (string-match
-                   tramp-gvfs-owncloud-default-prefix-regexp prefix))
-         (setq method "owncloud"))
+                   tramp-gvfs-nextcloud-default-prefix-regexp prefix))
+         (setq method "nextcloud"))
        (when (string-equal "google-drive" method)
          (setq method "gdrive"))
        (when (and (string-equal "http" method) (stringp uri))
@@ -1633,8 +1633,8 @@ file-notify events."
           (setq method "davs"))
         (when (and (string-equal "davs" method)
                    (string-match
-                    tramp-gvfs-owncloud-default-prefix-regexp prefix))
-          (setq method "owncloud"))
+                    tramp-gvfs-nextcloud-default-prefix-regexp prefix))
+          (setq method "nextcloud"))
         (when (string-equal "google-drive" method)
           (setq method "gdrive"))
         (when (and (string-equal "http" method) (stringp uri))
@@ -1688,7 +1688,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
         (localname (tramp-file-name-unquote-localname vec))
         (share (when (string-match "^/?\\([^/]+\\)" localname)
                  (match-string 1 localname)))
-        (ssl (if (string-match "^davs\\|^owncloud" method) "true" "false"))
+        (ssl (if (string-match "^davs\\|^nextcloud" method) "true" "false"))
         (mount-spec
           `(:array
             ,@(cond
@@ -1696,7 +1696,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
                 (list (tramp-gvfs-mount-spec-entry "type" "smb-share")
                       (tramp-gvfs-mount-spec-entry "server" host)
                       (tramp-gvfs-mount-spec-entry "share" share)))
-               ((string-match "^dav\\|^owncloud" method)
+               ((string-match "^dav\\|^nextcloud" method)
                 (list (tramp-gvfs-mount-spec-entry "type" "dav")
                       (tramp-gvfs-mount-spec-entry "host" host)
                       (tramp-gvfs-mount-spec-entry "ssl" ssl)))
@@ -1707,6 +1707,9 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
                ((string-equal "gdrive" method)
                 (list (tramp-gvfs-mount-spec-entry "type" "google-drive")
                       (tramp-gvfs-mount-spec-entry "host" host)))
+               ((string-equal "nextcloud" method)
+                (list (tramp-gvfs-mount-spec-entry "type" "owncloud")
+                      (tramp-gvfs-mount-spec-entry "host" host)))
                ((string-match "^http" method)
                 (list (tramp-gvfs-mount-spec-entry "type" "http")
                       (tramp-gvfs-mount-spec-entry
@@ -1980,6 +1983,8 @@ VEC is used only for traces."
                   :port (match-string 3 identity)))
        (when (string-equal (tramp-goa-name-method key) "google")
          (setf (tramp-goa-name-method key) "gdrive"))
+       (when (string-equal (tramp-goa-name-method key) "owncloud")
+         (setf (tramp-goa-name-method key) "nextcloud"))
        ;; Cache all properties.
        (dolist (prop (nconc account-properties files-properties))
          (tramp-set-connection-property key (car prop) (cdr prop)))
@@ -2086,7 +2091,7 @@ This uses \"avahi-browse\" in case D-Bus is not enabled 
in Avahi."
 ;; * (Customizable) unmount when exiting Emacs.  See tramp-archive.el.
 
 ;; * Host name completion for existing mount points (afp-server,
-;;   smb-server, google-drive, owncloud) or via smb-network or network.
+;;   smb-server, google-drive, nextcloud) or via smb-network or network.
 ;;
 ;; * Check, how two shares of the same SMB server can be mounted in
 ;;   parallel.
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 2d25350..86e82d4 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2547,7 +2547,11 @@ The method used must be an out-of-band method."
   "Like `make-directory' for Tramp files."
   (setq dir (expand-file-name dir))
   (with-parsed-tramp-file-name dir nil
-    (tramp-flush-directory-properties v (file-name-directory localname))
+    ;; When PARENTS is non-nil, DIR could be a chain of non-existent
+    ;; directories a/b/c/...  Instead of checking, we simply flush the
+    ;; whole cache.
+    (tramp-flush-directory-properties
+     v (if parents "/" (file-name-directory localname)))
     (save-excursion
       (tramp-barf-unless-okay
        v (format "%s %s"
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 48a45d7..a8a927a 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3608,16 +3608,20 @@ support symbolic links."
     ;; First, we must replace environment variables.
     (setq filename (tramp-replace-environment-variables filename))
     (with-parsed-tramp-file-name filename nil
-      ;; We do not want to replace environment variables, again.
+      ;; We do not want to replace environment variables, again.  "//"
+      ;; has a special meaning at the beginning of a file name on
+      ;; Cygwin and MS-Windows, we must remove it.
       (let (process-environment)
        ;; Ignore in LOCALNAME everything before "//" or "/~".
        (when (stringp localname)
          (if (string-match "//\\(/\\|~\\)" localname)
-             (setq filename (substitute-in-file-name localname))
+             (setq filename
+                    (replace-regexp-in-string
+                     "\\`/+" "/" (substitute-in-file-name localname)))
            (setq filename
                  (concat (file-remote-p filename)
-                         (tramp-run-real-handler
-                          'substitute-in-file-name (list localname)))))))
+                         (replace-regexp-in-string
+                           "\\`/+" "/" (substitute-in-file-name 
localname)))))))
       ;; "/m:h:~" does not work for completion.  We use "/m:h:~/".
       (if (and (stringp localname) (string-equal "~" localname))
          (concat filename "/")
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 3961ea6..d1eb3c3 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -12607,7 +12607,11 @@ comment at the start of cc-engine.el for more info."
                 (= (point) containing-sexp)))
          (if (eq (point) (c-point 'boi))
              (c-add-syntax 'brace-list-close (point))
-           (setq lim (c-most-enclosing-brace state-cache (point)))
+           (setq lim (or (save-excursion
+                           (and
+                            (c-back-over-member-initializers)
+                            (point)))
+                         (c-most-enclosing-brace state-cache (point))))
            (c-beginning-of-statement-1 lim nil nil t)
            (c-add-stmt-syntax 'brace-list-close nil t lim paren-state)))
 
@@ -12636,7 +12640,11 @@ comment at the start of cc-engine.el for more info."
              (goto-char containing-sexp))
            (if (eq (point) (c-point 'boi))
                (c-add-syntax 'brace-list-intro (point))
-             (setq lim (c-most-enclosing-brace state-cache (point)))
+             (setq lim (or (save-excursion
+                             (and
+                              (c-back-over-member-initializers)
+                              (point)))
+                           (c-most-enclosing-brace state-cache (point))))
              (c-beginning-of-statement-1 lim)
              (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state)))
 
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el
index ed71b86..685e171 100644
--- a/lisp/progmodes/subword.el
+++ b/lisp/progmodes/subword.el
@@ -110,9 +110,7 @@ called a `subword'.  Here are some examples:
   NSGraphicsContext  =>  \"NS\", \"Graphics\" and \"Context\"
 
 This mode changes the definition of a word so that word commands
-treat nomenclature boundaries as word boundaries.
-
-\\{subword-mode-map}"
+treat nomenclature boundaries as word boundaries."
     :lighter " ,"
     (when subword-mode (superword-mode -1))
     (subword-setup-buffer))
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 4d1ad03..7efbfc7 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -254,14 +254,22 @@ EVENT should be a scroll bar click or drag event."
   (let* ((start-position (event-start event))
         (window (nth 0 start-position))
         (portion-whole (nth 2 start-position)))
-    (save-excursion
-      (with-current-buffer (window-buffer window)
-       ;; Calculate position relative to the accessible part of the buffer.
-       (goto-char (+ (point-min)
-                     (scroll-bar-scale portion-whole
-                                       (- (point-max) (point-min)))))
-       (vertical-motion 0 window)
-       (set-window-start window (point))))))
+    ;; With 'scroll-bar-adjust-thumb-portion' nil and 'portion-whole'
+    ;; indicating that the buffer is fully visible, do not scroll the
+    ;; window since that might make it impossible to scroll it back
+    ;; with GTK's thumb (Bug#32002).
+    (when (or scroll-bar-adjust-thumb-portion
+              (not (numberp (car portion-whole)))
+              (not (numberp (cdr portion-whole)))
+              (/= (car portion-whole) (cdr portion-whole)))
+      (save-excursion
+        (with-current-buffer (window-buffer window)
+         ;; Calculate position relative to the accessible part of the buffer.
+         (goto-char (+ (point-min)
+                       (scroll-bar-scale portion-whole
+                                         (- (point-max) (point-min)))))
+         (vertical-motion 0 window)
+         (set-window-start window (point)))))))
 
 (defun scroll-bar-drag (event)
   "Scroll the window by dragging the scroll bar slider.
diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el
index e1a9b8e..86280c3 100644
--- a/lisp/shadowfile.el
+++ b/lisp/shadowfile.el
@@ -231,12 +231,12 @@ information defining the cluster.  For interactive use, 
call
 
 (defun shadow-site-name (site)
   "Return name if SITE has the form \"/name:\", otherwise SITE."
-  (if (string-match "\\`/\\(\\w+\\):\\'" site)
+  (if (string-match "\\`/\\([-.[:word:]]+\\):\\'" site)
       (match-string 1 site) site))
 
 (defun shadow-name-site (name)
   "Return \"/name:\" if NAME has word syntax, otherwise NAME."
-  (if (string-match "\\`\\w+\\'" name)
+  (if (string-match "\\`[-.[:word:]]+\\'" name)
       (format "/%s:"name) name))
 
 (defun shadow-site-primary (site)
@@ -307,14 +307,7 @@ Replace HOST, and NAME when non-nil."
     (if (null (tramp-file-name-method hup))
        (format
         "/%s:%s" (tramp-file-name-host hup) (tramp-file-name-localname hup))
-      (tramp-make-tramp-file-name
-       (tramp-file-name-method hup)
-       (tramp-file-name-user hup)
-       (tramp-file-name-domain hup)
-       (tramp-file-name-host hup)
-       (tramp-file-name-port hup)
-       (tramp-file-name-localname hup)
-       (tramp-file-name-hop hup)))))
+      (tramp-make-tramp-file-name hup))))
 
 (defun shadow-replace-name-component (fullname newname)
   "Return FULLNAME with the name component changed to NEWNAME."
@@ -635,17 +628,26 @@ Consider them as regular expressions if third arg REGEXP 
is true."
 
 (defun shadow-add-to-todo ()
   "If current buffer has shadows, add them to the list needing to be copied."
+  (message "shadow-add-to-todo 1 %s" (current-buffer))
+  (message "shadow-add-to-todo 2 %s" (buffer-file-name))
+  (message "shadow-add-to-todo 3 %s" (shadow-expand-file-name 
(buffer-file-name  (current-buffer))))
+  (message "shadow-add-to-todo 4 %s" (shadow-shadows-of 
(shadow-expand-file-name (buffer-file-name (current-buffer)))))
   (let ((shadows (shadow-shadows-of
                  (shadow-expand-file-name
                   (buffer-file-name (current-buffer))))))
     (when shadows
+      (message "shadow-add-to-todo 5 %s" shadows)
+      (message "shadow-add-to-todo 6 %s" shadow-files-to-copy)
+      (message "shadow-add-to-todo 7 %s" (shadow-union shadows 
shadow-files-to-copy))
       (setq shadow-files-to-copy
            (shadow-union shadows shadow-files-to-copy))
       (when (not shadow-inhibit-message)
        (message "%s" (substitute-command-keys
                       "Use \\[shadow-copy-files] to update shadows."))
        (sit-for 1))
-      (shadow-write-todo-file)))
+      (message "shadow-add-to-todo 8")
+      (shadow-write-todo-file)
+      (message "shadow-add-to-todo 9")))
   nil)     ; Return nil for write-file-functions
 
 (defun shadow-remove-from-todo (pair)
@@ -712,18 +714,26 @@ defined, the old hashtable info is invalid."
   "Write out information to `shadow-todo-file'.
 With non-nil argument also saves the buffer."
   (save-excursion
+    (message "shadow-write-todo-file 1 %s" shadow-todo-buffer)
     (if (not shadow-todo-buffer)
        (setq shadow-todo-buffer (find-file-noselect shadow-todo-file)))
+    (message "shadow-write-todo-file 2 %s" shadow-todo-buffer)
     (set-buffer shadow-todo-buffer)
+    (message "shadow-write-todo-file 3 %s" shadow-todo-buffer)
     (setq buffer-read-only nil)
     (delete-region (point-min) (point-max))
+    (message "shadow-write-todo-file 4 %s" shadow-todo-buffer)
     (shadow-insert-var 'shadow-files-to-copy)
-    (if save (shadow-save-todo-file))))
+    (message "shadow-write-todo-file 5 %s" save)
+    (if save (shadow-save-todo-file))
+    (message "shadow-write-todo-file 6 %s" save)))
 
 (defun shadow-save-todo-file ()
+  (message "shadow-save-todo-file 1 %s" shadow-todo-buffer)
   (if (and shadow-todo-buffer (buffer-modified-p shadow-todo-buffer))
       (with-current-buffer shadow-todo-buffer
-       (condition-case nil             ; have to continue even in case of
+        (message "shadow-save-todo-file 2 %s" shadow-todo-buffer)
+        (condition-case nil            ; have to continue even in case of
            (basic-save-buffer)         ; error, otherwise kill-emacs might
          (error                        ; not work!
           (message "WARNING: Can't save shadow todo file; it is locked!")
diff --git a/lisp/simple.el b/lisp/simple.el
index 6459531..8d77047 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8346,14 +8346,12 @@ LSHIFTBY is the numeric value of this modifier, in 
keyboard events.
 PREFIX is the string that represents this modifier in an event type symbol."
   (if (numberp event)
       (cond ((eq symbol 'control)
-            (if (and (<= (downcase event) ?z)
-                     (>= (downcase event) ?a))
-                (- (downcase event) ?a -1)
-              (if (and (<= (downcase event) ?Z)
-                       (>= (downcase event) ?A))
-                  (- (downcase event) ?A -1)
-                (logior (lsh 1 lshiftby) event))))
+            (if (<= 64 (upcase event) 95)
+                (- (upcase event) 64)
+              (logior (lsh 1 lshiftby) event)))
            ((eq symbol 'shift)
+             ;; FIXME: Should we also apply this "upcase" behavior of shift
+             ;; to non-ascii letters?
             (if (and (<= (downcase event) ?z)
                      (>= (downcase event) ?a))
                 (upcase event)
diff --git a/lisp/subr.el b/lisp/subr.el
index cc963dd..7313d3b 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -560,12 +560,6 @@ If N is omitted or nil, remove the last element."
           (if (> n 0) (setcdr (nthcdr (- (1- m) n) list) nil))
           list))))
 
-(defun proper-list-p (object)
-  "Return OBJECT's length if it is a proper list, nil otherwise.
-A proper list is neither circular nor dotted (i.e., its last cdr
-is nil)."
-  (and (listp object) (ignore-errors (length object))))
-
 (defun delete-dups (list)
   "Destructively remove `equal' duplicates from LIST.
 Store the result in LIST and return it.  LIST must be a proper list.
@@ -2310,7 +2304,7 @@ some sort of escape sequence, the ambiguity is resolved 
via `read-key-delay'."
 If optional CONFIRM is non-nil, read the password twice to make sure.
 Optional DEFAULT is a default password to use instead of empty input.
 
-This function echoes `.' for each character that the user types.
+This function echoes `*' for each character that the user types.
 You could let-bind `read-hide-char' to another hiding character, though.
 
 Once the caller uses the password, it can erase the password
@@ -2336,7 +2330,7 @@ by doing (clear-string STRING)."
                                      beg)))
              (dotimes (i (- end beg))
                (put-text-property (+ i beg) (+ 1 i beg)
-                                  'display (string (or read-hide-char ?.))))))
+                                  'display (string (or read-hide-char ?*))))))
           minibuf)
       (minibuffer-with-setup-hook
           (lambda ()
@@ -2351,7 +2345,7 @@ by doing (clear-string STRING)."
             (add-hook 'after-change-functions hide-chars-fun nil 'local))
         (unwind-protect
             (let ((enable-recursive-minibuffers t)
-                 (read-hide-char (or read-hide-char ?.)))
+                 (read-hide-char (or read-hide-char ?*)))
               (read-string prompt nil t default)) ; t = "no history"
           (when (buffer-live-p minibuf)
             (with-current-buffer minibuf
@@ -4698,25 +4692,6 @@ The properties used on SYMBOL are `composefunc', 
`sendfunc',
   (put symbol 'hookvar (or hookvar 'mail-send-hook)))
 
 
-(defun backtrace--print-frame (evald func args flags)
-  "Print a trace of a single stack frame to `standard-output'.
-EVALD, FUNC, ARGS, FLAGS are as in `mapbacktrace'."
-  (princ (if (plist-get flags :debug-on-exit) "* " "  "))
-  (cond
-   ((and evald (not debugger-stack-frame-as-list))
-    (cl-prin1 func)
-    (if args (cl-prin1 args) (princ "()")))
-   (t
-    (cl-prin1 (cons func args))))
-  (princ "\n"))
-
-(defun backtrace ()
-  "Print a trace of Lisp function calls currently active.
-Output stream used is value of `standard-output'."
-  (let ((print-level (or print-level 8))
-        (print-escape-control-characters t))
-    (mapbacktrace #'backtrace--print-frame 'backtrace)))
-
 (defun backtrace-frames (&optional base)
   "Collect all frames of current backtrace into a list.
 If non-nil, BASE should be a function, and frames before its
diff --git a/lisp/term.el b/lisp/term.el
index 121a22e..9f8f1f7 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -343,6 +343,7 @@
 (eval-when-compile (require 'cl-lib))
 (require 'ring)
 (require 'ehelp)
+(require 'comint) ; Password regexp.
 
 (declare-function ring-empty-p "ring" (ring))
 (declare-function ring-ref "ring" (ring index))
@@ -2215,6 +2216,7 @@ filter and C-g is pressed, this function returns nil 
rather than a string).
 Note that the keystrokes comprising the text can still be recovered
 \(temporarily) with \\[view-lossage].  This may be a security bug for some
 applications."
+  (declare (obsolete read-passwd "27.1"))
   (let ((ans "")
        (c 0)
        (echo-keystrokes 0)
@@ -2255,12 +2257,10 @@ applications."
 (defun term-send-invisible (str &optional proc)
   "Read a string without echoing.
 Then send it to the process running in the current buffer.  A new-line
-is additionally sent.  String is not saved on term input history list.
-Security bug: your string can still be temporarily recovered with
-\\[view-lossage]."
+is additionally sent.  String is not saved on term input history list."
   (interactive "P") ; Defeat snooping via C-x esc
   (when (not (stringp str))
-    (setq str (term-read-noecho "Non-echoed text: " t)))
+    (setq str (read-passwd "Non-echoed text: ")))
   (when (not proc)
     (setq proc (get-buffer-process (current-buffer))))
   (if (not proc) (error "Current buffer has no process")
@@ -2269,6 +2269,16 @@ Security bug: your string can still be temporarily 
recovered with
     (term-send-string proc str)
     (term-send-string proc "\n")))
 
+;; TODO: Maybe combine this with `comint-watch-for-password-prompt'.
+(defun term-watch-for-password-prompt (string)
+  "Prompt in the minibuffer for password and send without echoing.
+Checks if STRING contains a password prompt as defined by
+`comint-password-prompt-regexp'."
+  (when (term-in-line-mode)
+    (when (let ((case-fold-search t))
+            (string-match comint-password-prompt-regexp string))
+      (term-send-invisible (read-passwd string)))))
+
 
 ;;; Low-level process communication
 
@@ -3054,6 +3064,8 @@ See `term-prompt-regexp'."
          (term-handle-deferred-scroll))
 
        (set-marker (process-mark proc) (point))
+        (when (stringp decoded-substring)
+          (term-watch-for-password-prompt decoded-substring))
        (when save-point
          (goto-char save-point)
          (set-marker save-point nil))
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 4612e95..7fcb3bc 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -484,7 +484,7 @@ looks like an email address, \"ftp://\"; if it starts with
 
 (put 'url 'end-op (lambda () (end-of-thing 'url)))
 
-(put 'url 'beginning-op (lambda () (end-of-thing 'url)))
+(put 'url 'beginning-op (lambda () (beginning-of-thing 'url)))
 
 ;; The normal thingatpt mechanism doesn't work for complex regexps.
 ;; This should work for almost any regexp wherever we are in the
diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el
index b850350..ac94586 100644
--- a/lisp/vc/diff.el
+++ b/lisp/vc/diff.el
@@ -226,8 +226,9 @@ With prefix arg, prompt for diff switches."
   "View the differences between BUFFER and its associated file.
 This requires the external program `diff' to be in your `exec-path'."
   (interactive "bBuffer: ")
-  (with-current-buffer (get-buffer (or buffer (current-buffer)))
-    (diff buffer-file-name (current-buffer) nil 'noasync)))
+  (let ((buf (get-buffer (or buffer (current-buffer)))))
+    (with-current-buffer (or (buffer-base-buffer buf) buf)
+      (diff buffer-file-name (current-buffer) nil 'noasync))))
 
 (provide 'diff)
 
diff --git a/lisp/w32-fns.el b/lisp/w32-fns.el
index 825420c..bdba32c 100644
--- a/lisp/w32-fns.el
+++ b/lisp/w32-fns.el
@@ -280,7 +280,7 @@ bit output with no translation."
   (w32-add-charset-info "iso8859-13" 'w32-charset-baltic 1257)
   (w32-add-charset-info "koi8-r" 'w32-charset-russian 20866)
   (w32-add-charset-info "iso8859-5" 'w32-charset-russian 28595)
-  (w32-add-charset-info "tis620-2533" 'w32-charset-thai 874)
+  (w32-add-charset-info "iso8859-11" 'w32-charset-thai 874)
   (w32-add-charset-info "windows-1258" 'w32-charset-vietnamese 1258)
   (w32-add-charset-info "ksc5601.1992" 'w32-charset-johab 1361)
   (w32-add-charset-info "mac-roman" 'w32-charset-mac 10000)
diff --git a/lisp/wdired.el b/lisp/wdired.el
index bb60e77..be0bde2 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -255,6 +255,7 @@ See `wdired-mode'."
   (setq buffer-read-only nil)
   (dired-unadvertise default-directory)
   (add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t)
+  (add-hook 'after-change-functions 'wdired--restore-dired-filename-prop nil t)
   (setq major-mode 'wdired-mode)
   (setq mode-name "Editable Dired")
   (setq revert-buffer-function 'wdired-revert)
@@ -363,6 +364,7 @@ non-nil means return old filename."
   (setq mode-name "Dired")
   (dired-advertise)
   (remove-hook 'kill-buffer-hook 'wdired-check-kill-buffer t)
+  (remove-hook 'after-change-functions 'wdired--restore-dired-filename-prop t)
   (set (make-local-variable 'revert-buffer-function) 'dired-revert))
 
 
@@ -381,7 +383,6 @@ non-nil means return old filename."
 (defun wdired-finish-edit ()
   "Actually rename files based on your editing in the Dired buffer."
   (interactive)
-  (wdired-change-to-dired-mode)
   (let ((changes nil)
        (errors 0)
        files-deleted
@@ -423,6 +424,11 @@ non-nil means return old filename."
        (forward-line -1)))
     (when files-renamed
       (setq errors (+ errors (wdired-do-renames files-renamed))))
+    ;; We have to be in wdired-mode when wdired-do-renames is executed
+    ;; so that wdired--restore-dired-filename-prop runs, but we have
+    ;; to change back to dired-mode before reverting the buffer to
+    ;; avoid using wdired-revert, which changes back to wdired-mode.
+    (wdired-change-to-dired-mode)
     (if changes
        (progn
          ;; If we are displaying a single file (rather than the
@@ -543,19 +549,25 @@ and proceed depending on the answer."
     (goto-char (point-max))
     (forward-line -1)
     (let ((done nil)
+          (failed t)
          curr-filename)
       (while (and (not done) (not (bobp)))
         (setq curr-filename (wdired-get-filename nil t))
         (if (equal curr-filename filename-ori)
-            (progn
-              (setq done t)
-              (let ((inhibit-read-only t))
-                (dired-move-to-filename)
-                (search-forward (wdired-get-filename t) nil t)
-                (replace-match (file-name-nondirectory filename-ori) t t))
-              (dired-do-create-files-regexp
-               (function dired-rename-file)
-               "Move" 1 ".*" filename-new nil t))
+            (unwind-protect
+                (progn
+                  (setq done t)
+                  (let ((inhibit-read-only t))
+                    (dired-move-to-filename)
+                    (search-forward (wdired-get-filename t) nil t)
+                    (replace-match (file-name-nondirectory filename-ori) t t))
+                  (dired-do-create-files-regexp
+                   (function dired-rename-file)
+                   "Move" 1 ".*" filename-new nil t)
+                  (setq failed nil))
+              ;; If user types C-g when prompted to change the file
+              ;; name, make sure we return to dired-mode.
+              (when failed (wdired-change-to-dired-mode)))
          (forward-line -1))))))
 
 ;; marks a list of files for deletion
@@ -586,6 +598,25 @@ Optional arguments are ignored."
        (not (y-or-n-p "Buffer changed. Discard changes and kill buffer? ")))
       (error "Error")))
 
+;; Added to after-change-functions in wdired-change-to-wdired-mode to
+;; ensure that, on editing a file name, new characters get the
+;; dired-filename text property, which allows functions that look for
+;; this property (e.g. dired-isearch-filenames) to work in wdired-mode
+;; and also avoids an error with non-nil wdired-use-interactive-rename
+;; (bug#32173).
+(defun wdired--restore-dired-filename-prop (beg end _len)
+  (save-match-data
+    (save-excursion
+      (beginning-of-line)
+      (when (re-search-forward directory-listing-before-filename-regexp
+                               (line-end-position) t)
+        (setq beg (point)
+              end (if (and (file-symlink-p (dired-get-filename))
+                           (search-forward " -> " (line-end-position) t))
+                      (goto-char (match-beginning 0))
+                    (line-end-position)))
+        (put-text-property beg end 'dired-filename t)))))
+
 (defun wdired-next-line (arg)
   "Move down lines then position at filename or the current column.
 See `wdired-use-dired-vertical-movement'.  Optional prefix ARG
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index a6e3be3..494c77c 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -101,6 +101,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module gettimeofday:
   # Code from module gitlog-to-changelog:
   # Code from module group-member:
+  # Code from module ieee754-h:
   # Code from module ignore-value:
   # Code from module include_next:
   # Code from module intprops:
@@ -295,6 +296,7 @@ AC_DEFUN([gl_INIT],
     gl_PREREQ_GETTIMEOFDAY
   fi
   gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
+  gl_IEEE754_H
   gl_INTTYPES_INCOMPLETE
   AC_REQUIRE([gl_LARGEFILE])
   gl_LIMITS_H
@@ -895,6 +897,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/gettimeofday.c
   lib/gl_openssl.h
   lib/group-member.c
+  lib/ieee754.in.h
   lib/ignore-value.h
   lib/intprops.h
   lib/inttypes.in.h
@@ -1017,6 +1020,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/gl-openssl.m4
   m4/gnulib-common.m4
   m4/group-member.m4
+  m4/ieee754-h.m4
   m4/include_next.m4
   m4/inttypes.m4
   m4/largefile.m4
diff --git a/m4/ieee754-h.m4 b/m4/ieee754-h.m4
new file mode 100644
index 0000000..bf7c332
--- /dev/null
+++ b/m4/ieee754-h.m4
@@ -0,0 +1,21 @@
+# Configure ieee754-h module
+
+dnl Copyright 2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_IEEE754_H],
+[
+  AC_REQUIRE([AC_C_BIGENDIAN])
+  AC_CHECK_HEADERS_ONCE([ieee754.h])
+  if test $ac_cv_header_ieee754_h = yes; then
+    IEEE754_H=
+  else
+    IEEE754_H=ieee754.h
+    AC_DEFINE([_GL_REPLACE_IEEE754_H], 1,
+              [Define to 1 if <ieee754.h> is missing.])
+  fi
+  AC_SUBST([IEEE754_H])
+  AM_CONDITIONAL([GL_GENERATE_IEEE754_H], [test -n "$IEEE754_H"])
+])
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index ff43178..e4dec04 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -34,6 +34,11 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 # ifdef __MINGW64_VERSION_MAJOR
 #  define MINGW_W64
 # endif
+# if defined __MINGW32_VERSION && __MINGW32_VERSION >= 5001000L
+/* Avoid warnings about gettimeofday being deprecated.  */
+#  undef __POSIX_2008_DEPRECATED
+#  define __POSIX_2008_DEPRECATED
+# endif
 #endif
 
 /* #undef const */
@@ -455,7 +460,12 @@ extern char *get_emacs_configuration_options (void);
    windows.h.  For this to have proper effect, config.h must always be
    included before windows.h.  */
 #define _WINSOCKAPI_    1
-#define _WINSOCK_H
+#if !(defined __MINGW32_VERSION && __MINGW32_VERSION >= 5000002L)
+/* mingw.org's MinGW 5.x changed how it includes winsock.h and time.h,
+   and now defining _WINSOCK_H skips the definition of struct timeval,
+   which we don't want.  */
+# define _WINSOCK_H
+#endif
 
 /* Defines size_t and alloca ().  */
 #include <stdlib.h>
diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h
index 2582cbd..de282c4 100644
--- a/nt/inc/sys/socket.h
+++ b/nt/inc/sys/socket.h
@@ -49,6 +49,11 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #define timeval ws_timeval
 #endif
 
+#if defined __MINGW32_VERSION && __MINGW32_VERSION >= 5000002L
+/* Need winerror.h before winsock2.h with mingw.org's MinGW 5.x,
+   otherwise some error codes are not defined.  */
+# include <winerror.h>
+#endif
 #include <winsock2.h>
 #include <ws2tcpip.h>
 /* process.c uses uint16_t (from C99) for IPv6, but
diff --git a/src/character.c b/src/character.c
index 6a68980..8920da2 100644
--- a/src/character.c
+++ b/src/character.c
@@ -34,6 +34,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "character.h"
 #include "buffer.h"
+#include "dispextern.h"
 #include "composite.h"
 #include "disptab.h"
 
@@ -288,10 +289,15 @@ char_width (int c, struct Lisp_Char_Table *dp)
       if (VECTORP (disp))
        for (i = 0, width = 0; i < ASIZE (disp); i++)
          {
+           int c = -1;
            ch = AREF (disp, i);
-           if (CHARACTERP (ch))
+           if (GLYPH_CODE_P (ch))
+             c = GLYPH_CODE_CHAR (ch);
+           else if (CHARACTERP (ch))
+             c = XFASTINT (ch);
+           if (c >= 0)
              {
-               int w = CHARACTER_WIDTH (XFASTINT (ch));
+               int w = CHARACTER_WIDTH (c);
                if (INT_ADD_WRAPV (width, w, &width))
                  string_overflow ();
              }
diff --git a/src/data.c b/src/data.c
index c8beeda..aaccb67 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2812,10 +2812,6 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args)
   return val;
 }
 
-#ifndef isnan
-# define isnan(x) ((x) != (x))
-#endif
-
 static Lisp_Object
 float_arith_driver (double accum, ptrdiff_t argnum, enum arithop code,
                    ptrdiff_t nargs, Lisp_Object *args)
diff --git a/src/editfns.c b/src/editfns.c
index ccc0d27..0fbc5aa 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3256,21 +3256,9 @@ differences between the two buffers.  */)
      Instead, we announce a single modification for the entire
      modified region.  But don't do that if the caller inhibited
      modification hooks, because then they don't want that.  */
-  ptrdiff_t from, to;
   if (!inhibit_modification_hooks)
     {
-      ptrdiff_t k, l;
-
-      /* Find the first character position to be changed.  */
-      for (k = 0; k < size_a && !bit_is_set (ctx.deletions, k); k++)
-       ;
-      from = BEGV + k;
-
-      /* Find the last character position to be changed.  */
-      for (l = size_a; l > 0 && !bit_is_set (ctx.deletions, l - 1); l--)
-       ;
-      to = BEGV + l;
-      prepare_to_modify_buffer (from, to, NULL);
+      prepare_to_modify_buffer (BEGV, ZV, NULL);
       specbind (Qinhibit_modification_hooks, Qt);
       modification_hooks_inhibited = true;
     }
@@ -3322,9 +3310,8 @@ differences between the two buffers.  */)
 
   if (modification_hooks_inhibited)
     {
-      ptrdiff_t updated_to = to + ZV - BEGV - size_a;
-      signal_after_change (from, to - from, updated_to - from);
-      update_compositions (from, updated_to, CHECK_INSIDE);
+      signal_after_change (BEGV, size_a, ZV - BEGV);
+      update_compositions (BEGV, ZV, CHECK_INSIDE);
     }
 
   return Qnil;
@@ -4196,13 +4183,13 @@ contain either numbered or unnumbered %-sequences but 
not both, except
 that %% can be mixed with numbered %-sequences.
 
 The + flag character inserts a + before any nonnegative number, while a
-space inserts a space before any nonnegative number; these flags only
-affect %d, %e, %f, and %g sequences, and the + flag takes precedence.
+space inserts a space before any nonnegative number; these flags
+affect only numeric %-sequences, and the + flag takes precedence.
 The - and 0 flags affect the width specifier, as described below.
 
 The # flag means to use an alternate display form for %o, %x, %X, %e,
 %f, and %g sequences: for %o, it ensures that the result begins with
-\"0\"; for %x and %X, it prefixes the result with \"0x\" or \"0X\";
+\"0\"; for %x and %X, it prefixes nonzero results with \"0x\" or \"0X\";
 for %e and %f, it causes a decimal point to be included even if the
 precision is zero; for %g, it causes a decimal point to be
 included even if the precision is zero, and also forces trailing
@@ -4736,10 +4723,22 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool 
message)
                }
              else
                {
-                 /* Don't sign-extend for octal or hex printing.  */
                  uprintmax_t x;
+                 bool negative;
                  if (INTEGERP (arg))
-                   x = XUINT (arg);
+                   {
+                     if (binary_as_unsigned)
+                       {
+                         x = XUINT (arg);
+                         negative = false;
+                       }
+                     else
+                       {
+                         EMACS_INT i = XINT (arg);
+                         negative = i < 0;
+                         x = negative ? -i : i;
+                       }
+                   }
                  else
                    {
                      double d = XFLOAT_DATA (arg);
@@ -4747,8 +4746,13 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool 
message)
                      if (! (0 <= d && d < uprintmax + 1))
                        xsignal1 (Qoverflow_error, arg);
                      x = d;
+                     negative = false;
                    }
-                 sprintf_bytes = sprintf (sprintf_buf, convspec, prec, x);
+                 sprintf_buf[0] = negative ? '-' : plus_flag ? '+' : ' ';
+                 bool signedp = negative | plus_flag | space_flag;
+                 sprintf_bytes = sprintf (sprintf_buf + signedp,
+                                          convspec, prec, x);
+                 sprintf_bytes += signedp;
                }
 
              /* Now the length of the formatted item is known, except it omits
@@ -5558,6 +5562,22 @@ functions if all the text being accessed has this 
property.  */);
   DEFVAR_LISP ("operating-system-release", Voperating_system_release,
               doc: /* The release of the operating system Emacs is running on. 
 */);
 
+  DEFVAR_BOOL ("binary-as-unsigned",
+              binary_as_unsigned,
+              doc: /* Non-nil means `format' %x and %o treat integers as 
unsigned.
+This has machine-dependent results.  Nil means to treat integers as
+signed, which is portable; for example, if N is a negative integer,
+(read (format "#x%x") N) returns N only when this variable is nil.
+
+This variable is experimental; email address@hidden if you need
+it to be non-nil.  */);
+  /* For now, default to true if bignums exist, false in traditional Emacs.  */
+#ifdef lisp_h_FIXNUMP
+  binary_as_unsigned = false;
+#else
+  binary_as_unsigned = true;
+#endif
+
   defsubr (&Spropertize);
   defsubr (&Schar_equal);
   defsubr (&Sgoto_char);
diff --git a/src/emacs.c b/src/emacs.c
index 861d707..130a9f8 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2019,6 +2019,10 @@ all of which are called before Emacs is actually killed. 
 */
 {
   int exit_code;
 
+#ifdef HAVE_LIBSYSTEMD
+  sd_notify(0, "STOPPING=1");
+#endif /* HAVE_LIBSYSTEMD */
+
   /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
      set.  */
   waiting_for_input = 0;
@@ -2479,6 +2483,13 @@ from the parent process and its tty file descriptors.  
*/)
     error ("This function can only be called after loading the init files");
 #ifndef WINDOWSNT
 
+  if (daemon_type == 1)
+    {
+#ifdef HAVE_LIBSYSTEMD
+      sd_notify(0, "READY=1");
+#endif /* HAVE_LIBSYSTEMD */
+    }
+
   if (daemon_type == 2)
     {
       int nfd;
diff --git a/src/eval.c b/src/eval.c
index 256ca8f..5964dd1 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1732,28 +1732,12 @@ xsignal3 (Lisp_Object error_symbol, Lisp_Object arg1, 
Lisp_Object arg2, Lisp_Obj
 }
 
 /* Signal `error' with message S, and additional arg ARG.
-   If ARG is not a genuine list, make it a one-element list.  */
+   If ARG is not a proper list, make it a one-element list.  */
 
 void
 signal_error (const char *s, Lisp_Object arg)
 {
-  Lisp_Object tortoise, hare;
-
-  hare = tortoise = arg;
-  while (CONSP (hare))
-    {
-      hare = XCDR (hare);
-      if (!CONSP (hare))
-       break;
-
-      hare = XCDR (hare);
-      tortoise = XCDR (tortoise);
-
-      if (EQ (hare, tortoise))
-       break;
-    }
-
-  if (!NILP (hare))
+  if (NILP (Fproper_list_p (arg)))
     arg = list1 (arg);
 
   xsignal (Qerror, Fcons (build_string (s), arg));
diff --git a/src/fileio.c b/src/fileio.c
index b92492c..2dcfb73 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2296,6 +2296,21 @@ The arg must be a string.  */)
   if (!NILP (handler))
     return call2 (handler, Qfile_name_case_insensitive_p, filename);
 
+  /* If the file doesn't exist, move up the filesystem tree until we
+     reach an existing directory or the root.  */
+  if (NILP (Ffile_exists_p (filename)))
+    {
+      filename = Ffile_name_directory (filename);
+      while (NILP (Ffile_exists_p (filename)))
+       {
+         Lisp_Object newname = expand_and_dir_to_file (filename);
+         /* Avoid infinite loop if the root is reported as non-existing
+            (impossible?).  */
+         if (!NILP (Fstring_equal (newname, filename)))
+           break;
+         filename = newname;
+       }
+    }
   filename = ENCODE_FILE (filename);
   return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil;
 }
diff --git a/src/floatfns.c b/src/floatfns.c
index e7d404a..45e786f 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -47,13 +47,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <count-leading-zeros.h>
 
-#ifndef isfinite
-# define isfinite(x) ((x) - (x) == 0)
-#endif
-#ifndef isnan
-# define isnan(x) ((x) != (x))
-#endif
-
 /* Check that X is a floating point number.  */
 
 static void
diff --git a/src/fns.c b/src/fns.c
index e7424c3..5247140 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -144,6 +144,28 @@ which is at least the number of distinct elements.  */)
   return make_fixnum_or_float (len);
 }
 
+DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0,
+       doc: /* Return OBJECT's length if it is a proper list, nil otherwise.
+A proper list is neither circular nor dotted (i.e., its last cdr is nil).  */
+       attributes: const)
+  (Lisp_Object object)
+{
+  intptr_t len = 0;
+  Lisp_Object last_tail = object;
+  Lisp_Object tail = object;
+  FOR_EACH_TAIL_SAFE (tail)
+    {
+      len++;
+      rarely_quit (len);
+      last_tail = XCDR (tail);
+    }
+  if (!NILP (last_tail))
+    return Qnil;
+  if (MOST_POSITIVE_FIXNUM < len)
+    xsignal0 (Qoverflow_error);
+  return make_number (len);
+}
+
 DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0,
        doc: /* Return the number of bytes in STRING.
 If STRING is multibyte, this may be greater than the length of STRING.  */)
@@ -5295,6 +5317,7 @@ this variable.  */);
   defsubr (&Srandom);
   defsubr (&Slength);
   defsubr (&Ssafe_length);
+  defsubr (&Sproper_list_p);
   defsubr (&Sstring_bytes);
   defsubr (&Sstring_distance);
   defsubr (&Sstring_equal);
diff --git a/src/json.c b/src/json.c
index ea941d7..afdd9a2 100644
--- a/src/json.c
+++ b/src/json.c
@@ -7,7 +7,7 @@ This file is part of GNU Emacs.
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or (at
-nyour option) any later version.
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/src/keyboard.c b/src/keyboard.c
index 01d7ce9..7ab9a60 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11820,10 +11820,10 @@ if the command is in this list, the selection is not 
updated.  */);
 
   DEFVAR_LISP ("debug-on-event",
                Vdebug_on_event,
-               doc: /* Enter debugger on this event.  When Emacs
-receives the special event specified by this variable, it will try to
-break into the debugger as soon as possible instead of processing the
-event normally through `special-event-map'.
+               doc: /* Enter debugger on this event.
+When Emacs receives the special event specified by this variable,
+it will try to break into the debugger as soon as possible instead
+of processing the event normally through `special-event-map'.
 
 Currently, the only supported values for this
 variable are `sigusr1' and `sigusr2'.  */);
@@ -11831,21 +11831,23 @@ variable are `sigusr1' and `sigusr2'.  */);
 
   DEFVAR_BOOL ("attempt-stack-overflow-recovery",
                attempt_stack_overflow_recovery,
-               doc: /* If non-nil, attempt to recover from C stack
-overflow.  This recovery is unsafe and may lead to deadlocks or data
+               doc: /* If non-nil, attempt to recover from C stack overflows.
+This recovery is potentially unsafe and may lead to deadlocks or data
 corruption, but it usually works and may preserve modified buffers
 that would otherwise be lost.  If nil, treat stack overflow like any
-other kind of crash.  */);
+other kind of crash or fatal error.  */);
   attempt_stack_overflow_recovery = true;
 
   DEFVAR_BOOL ("attempt-orderly-shutdown-on-fatal-signal",
                attempt_orderly_shutdown_on_fatal_signal,
-               doc: /* If non-nil, attempt to perform an orderly
-shutdown when Emacs receives a fatal signal (e.g., a crash).
-This cleanup is unsafe and may lead to deadlocks or data corruption,
-but it usually works and may preserve modified buffers that would
-otherwise be lost.  If nil, crash immediately in response to fatal
-signals.  */);
+               doc: /* If non-nil, attempt orderly shutdown on fatal signals.
+By default this variable is non-nil, and Emacs attempts to perform
+an orderly shutdown when it catches a fatal signal (e.g., a crash).
+The orderly shutdown includes an attempt to auto-save your unsaved edits
+and other useful cleanups.  These cleanups are potentially unsafe and may
+lead to deadlocks or data corruption, but it usually works and may
+preserve data in modified buffers that would otherwise be lost.
+If nil, Emacs crashes immediately in response to fatal signals.  */);
   attempt_orderly_shutdown_on_fatal_signal = true;
 
   /* Create the initial keyboard.  Qt means 'unset'.  */
diff --git a/src/lisp.h b/src/lisp.h
index 8ddd363d2..bdece81 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2670,17 +2670,14 @@ XFLOAT_DATA (Lisp_Object f)
 
 /* Most hosts nowadays use IEEE floating point, so they use IEC 60559
    representations, have infinities and NaNs, and do not trap on
-   exceptions.  Define IEEE_FLOATING_POINT if this host is one of the
+   exceptions.  Define IEEE_FLOATING_POINT to 1 if this host is one of the
    typical ones.  The C11 macro __STDC_IEC_559__ is close to what is
    wanted here, but is not quite right because Emacs does not require
    all the features of C11 Annex F (and does not require C11 at all,
    for that matter).  */
-enum
-  {
-    IEEE_FLOATING_POINT
-      = (FLT_RADIX == 2 && FLT_MANT_DIG == 24
-        && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
-  };
+
+#define IEEE_FLOATING_POINT (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
+                            && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
 
 /* A character, declared with the following typedef, is a member
    of some character set associated with the current buffer.  */
@@ -4699,7 +4696,7 @@ enum
 #define FOR_EACH_TAIL(tail) \
   FOR_EACH_TAIL_INTERNAL (tail, circular_list (tail), true)
 
-/* Like FOR_EACH_TAIL (LIST), except do not signal or quit.
+/* Like FOR_EACH_TAIL (TAIL), except do not signal or quit.
    If the loop exits due to a cycle, TAIL’s value is undefined.  */
 
 #define FOR_EACH_TAIL_SAFE(tail) \
diff --git a/src/lread.c b/src/lread.c
index 50fc6ef..9a025d8 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -72,6 +72,10 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #define file_tell ftell
 #endif
 
+#if IEEE_FLOATING_POINT
+# include <ieee754.h>
+#endif
+
 /* The objects or placeholders read with the #n=object form.
 
    A hash table maps a number to either a placeholder (while the
@@ -3752,14 +3756,18 @@ string_to_number (char const *string, int base, int 
flags)
              cp += 3;
              value = INFINITY;
            }
+#if IEEE_FLOATING_POINT
          else if (cp[-1] == '+'
                   && cp[0] == 'N' && cp[1] == 'a' && cp[2] == 'N')
            {
              state |= E_EXP;
              cp += 3;
-             /* NAN is a "positive" NaN on all known Emacs hosts.  */
-             value = NAN;
+             union ieee754_double u
+               = { .ieee_nan = { .exponent = -1, .quiet_nan = 1,
+                                 .mantissa0 = n >> 31 >> 1, .mantissa1 = n }};
+             value = u.d;
            }
+#endif
          else
            cp = ecp;
        }
diff --git a/src/print.c b/src/print.c
index 7159195..34c7fa1 100644
--- a/src/print.c
+++ b/src/print.c
@@ -38,6 +38,11 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <c-ctype.h>
 #include <float.h>
 #include <ftoastr.h>
+#include <math.h>
+
+#if IEEE_FLOATING_POINT
+# include <ieee754.h>
+#endif
 
 #ifdef WINDOWSNT
 # include <sys/socket.h> /* for F_DUPFD_CLOEXEC */
@@ -1001,43 +1006,22 @@ float_to_string (char *buf, double data)
   int width;
   int len;
 
-  /* Check for plus infinity in a way that won't lose
-     if there is no plus infinity.  */
-  if (data == data / 2 && data > 1.0)
-    {
-      static char const infinity_string[] = "1.0e+INF";
-      strcpy (buf, infinity_string);
-      return sizeof infinity_string - 1;
-    }
-  /* Likewise for minus infinity.  */
-  if (data == data / 2 && data < -1.0)
+  if (isinf (data))
     {
       static char const minus_infinity_string[] = "-1.0e+INF";
-      strcpy (buf, minus_infinity_string);
-      return sizeof minus_infinity_string - 1;
+      bool positive = 0 < data;
+      strcpy (buf, minus_infinity_string + positive);
+      return sizeof minus_infinity_string - 1 - positive;
     }
-  /* Check for NaN in a way that won't fail if there are no NaNs.  */
-  if (! (data * 0.0 >= 0.0))
+#if IEEE_FLOATING_POINT
+  if (isnan (data))
     {
-      /* Prepend "-" if the NaN's sign bit is negative.
-        The sign bit of a double is the bit that is 1 in -0.0.  */
-      static char const NaN_string[] = "0.0e+NaN";
-      int i;
-      union { double d; char c[sizeof (double)]; } u_data, u_minus_zero;
-      bool negative = 0;
-      u_data.d = data;
-      u_minus_zero.d = - 0.0;
-      for (i = 0; i < sizeof (double); i++)
-       if (u_data.c[i] & u_minus_zero.c[i])
-         {
-           *buf = '-';
-           negative = 1;
-           break;
-         }
-
-      strcpy (buf + negative, NaN_string);
-      return negative + sizeof NaN_string - 1;
+      union ieee754_double u = { .d = data };
+      uprintmax_t hi = u.ieee_nan.mantissa0;
+      return sprintf (buf, &"-%"pMu".0e+NaN"[!u.ieee_nan.negative],
+                     (hi << 31 << 1) + u.ieee_nan.mantissa1);
     }
+#endif
 
   if (NILP (Vfloat_output_format)
       || !STRINGP (Vfloat_output_format))
diff --git a/src/textprop.c b/src/textprop.c
index fe5b61e..ea1ae3b 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1350,6 +1350,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, 
Lisp_Object properties,
 {
   register INTERVAL i;
   Lisp_Object ostart, oend;
+  bool first_time = true;
 
   ostart = start;
   oend = end;
@@ -1372,6 +1373,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, 
Lisp_Object properties,
       return Qt;
     }
 
+ retry:
   i = validate_interval_range (object, &start, &end, soft);
 
   if (!i)
@@ -1391,8 +1393,22 @@ set_text_properties (Lisp_Object start, Lisp_Object end, 
Lisp_Object properties,
        return Qnil;
     }
 
-  if (BUFFERP (object) && !NILP (coherent_change_p))
-    modify_text_properties (object, start, end);
+  if (BUFFERP (object) && !NILP (coherent_change_p) && first_time)
+    {
+      ptrdiff_t prev_length = LENGTH (i);
+      ptrdiff_t prev_pos = i->position;
+
+      modify_text_properties (object, start, end);
+      /* If someone called us recursively as a side effect of
+        modify_text_properties, and changed the intervals behind our
+        back, we cannot continue with I, because its data changed.
+        So we restart the interval analysis anew.  */
+      if (LENGTH (i) != prev_length || i->position != prev_pos)
+       {
+         first_time = false;
+         goto retry;
+       }
+    }
 
   set_text_properties_1 (start, end, properties, object, i);
 
diff --git a/src/xdisp.c b/src/xdisp.c
index 316c12e..8f89ec5 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -265,7 +265,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
    character to be delivered is a composed character, the iteration
    calls composition_reseat_it and next_element_from_composition.  If
    they succeed to compose the character with one or more of the
-   following characters, the whole sequence of characters that where
+   following characters, the whole sequence of characters that were
    composed is recorded in the `struct composition_it' object that is
    part of the buffer iterator.  The composed sequence could produce
    one or more font glyphs (called "grapheme clusters") on the screen.
@@ -16916,6 +16916,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
       /* We used to issue a CHECK_MARGINS argument to try_window here,
         but this causes scrolling to fail when point begins inside
         the scroll margin (bug#148) -- cyd  */
+      clear_glyph_matrix (w->desired_matrix);
       if (!try_window (window, startp, 0))
        {
          w->force_start = true;
diff --git a/test/lisp/calendar/todo-mode-tests.el 
b/test/lisp/calendar/todo-mode-tests.el
index 159294f..325faef 100644
--- a/test/lisp/calendar/todo-mode-tests.el
+++ b/test/lisp/calendar/todo-mode-tests.el
@@ -25,6 +25,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'todo-mode)
 
 (defvar todo-test-data-dir
@@ -561,11 +562,12 @@ source file is different."
      ;; Headers in the todo file are still hidden.
      (should (equal (overlay-get (todo-get-overlay 'header) 'display) "")))))
 
-(defun todo-test--insert-item (item &optional priority)
+(defun todo-test--insert-item (item &optional priority
+                                    _arg diary-type date-type time where)
   "Insert string ITEM into current category with priority PRIORITY.
-Use defaults for all other item insertion parameters.  This
-provides a noninteractive API for todo-insert-item for use in
-automatic testing."
+The remaining arguments (except _ARG, which is ignored) specify
+item insertion parameters.  This provides a noninteractive API
+for todo-insert-item for use in automatic testing."
   (cl-letf (((symbol-function 'read-from-minibuffer)
              (lambda (_prompt) item))
             ((symbol-function 'read-number) ; For todo-set-item-priority
@@ -581,6 +583,186 @@ automatic testing."
      (todo-test--insert-item item 1)
      (should (equal (overlay-get (todo-get-overlay 'header) 'display) "")))))
 
+(defun todo-test--done-items-separator (&optional eol)
+  "Set up test of command interaction with done items separator.
+With non-nil argument EOL, return the position at the end of the
+separator, otherwise, return the position at the beginning."
+  (todo-test--show 1)
+  (goto-char (point-max))
+  ;; See comment about recentering in todo-test-raise-lower-priority.
+  (set-window-buffer nil (current-buffer))
+  (todo-toggle-view-done-items)
+  ;; FIXME: Point should now be on the first done item, and in batch
+  ;; testing it is, so we have to move back one line to the done items
+  ;; separator; but for some reason, in the graphical test
+  ;; environment, it stays on the last empty line of the todo items
+  ;; section, so there we have to advance one character to the done
+  ;; items separator.
+  (if (display-graphic-p)
+      (forward-char)
+    (forward-line -1))
+  (if eol (forward-char)))
+
+(ert-deftest todo-test-done-items-separator01-bol ()
+  "Test item copying and here insertion at BOL of separator.
+Both should be user errors."
+  (with-todo-test
+   (todo-test--done-items-separator)
+   (let* ((copy-err "Item copying is not valid here")
+          (here-err "Item insertion is not valid here")
+          (insert-item-test (lambda (where)
+                              (should-error (todo-insert-item--basic
+                                             nil nil nil nil where)))))
+     (should (string= copy-err (cadr (funcall insert-item-test 'copy))))
+     (should (string= here-err (cadr (funcall insert-item-test 'here)))))))
+
+(ert-deftest todo-test-done-items-separator01-eol ()
+  "Test item copying and here insertion at EOL of separator.
+Both should be user errors."
+  (with-todo-test
+   (todo-test--done-items-separator 'eol)
+   (let* ((copy-err "Item copying is not valid here")
+          (here-err "Item insertion is not valid here")
+          (insert-item-test (lambda (where)
+                              (should-error (todo-insert-item--basic
+                                             nil nil nil nil where)))))
+     (should (string= copy-err (cadr (funcall insert-item-test 'copy))))
+     (should (string= here-err (cadr (funcall insert-item-test 'here)))))))
+
+(ert-deftest todo-test-done-items-separator02-bol ()
+  "Test item editing commands at BOL of done items separator.
+They should all be noops."
+  (with-todo-test
+   (todo-test--done-items-separator)
+   (should-not (todo-item-done))
+   (should-not (todo-raise-item-priority))
+   (should-not (todo-lower-item-priority))
+   (should-not (called-interactively-p #'todo-set-item-priority))
+   (should-not (called-interactively-p #'todo-move-item))
+   (should-not (called-interactively-p #'todo-delete-item))
+   (should-not (called-interactively-p #'todo-edit-item))))
+
+(ert-deftest todo-test-done-items-separator02-eol ()
+  "Test item editing command at EOL of done items separator.
+They should all be noops."
+  (with-todo-test
+   (todo-test--done-items-separator 'eol)
+   (should-not (todo-item-done))
+   (should-not (todo-raise-item-priority))
+   (should-not (todo-lower-item-priority))
+   (should-not (called-interactively-p #'todo-set-item-priority))
+   (should-not (called-interactively-p #'todo-move-item))
+   (should-not (called-interactively-p #'todo-delete-item))
+   (should-not (called-interactively-p #'todo-edit-item))))
+
+(ert-deftest todo-test-done-items-separator03-bol ()
+  "Test item marking at BOL of done items separator.
+This should be a noop, adding no marks to the category."
+  (with-todo-test
+   (todo-test--done-items-separator)
+   (call-interactively #'todo-toggle-mark-item)
+   (should-not (assoc (todo-current-category) todo-categories-with-marks))))
+
+(ert-deftest todo-test-done-items-separator03-eol ()
+  "Test item marking at EOL of done items separator.
+This should be a noop, adding no marks to the category."
+  (with-todo-test
+   (todo-test--done-items-separator 'eol)
+   (call-interactively #'todo-toggle-mark-item)
+   (should-not (assoc (todo-current-category) todo-categories-with-marks))))
+
+(ert-deftest todo-test-done-items-separator04-bol ()
+  "Test moving to previous item from BOL of done items separator.
+This should move point to the last not done todo item."
+  (with-todo-test
+   (todo-test--done-items-separator)
+   (let ((last-item (save-excursion
+                      ;; Move to empty line after last todo item.
+                      (forward-line -1)
+                      (todo-previous-item)
+                      (todo-item-string))))
+     (should (string= last-item (save-excursion
+                                  (todo-previous-item)
+                                  (todo-item-string)))))))
+
+(ert-deftest todo-test-done-items-separator04-eol ()
+  "Test moving to previous item from EOL of done items separator.
+This should move point to the last not done todo item."
+  (with-todo-test
+   (todo-test--done-items-separator 'eol)
+   (let ((last-item (save-excursion
+                      ;; Move to empty line after last todo item.
+                      (forward-line -1)
+                      (todo-previous-item)
+                      (todo-item-string))))
+     (should (string= last-item (save-excursion
+                                  (todo-previous-item)
+                                  (todo-item-string)))))))
+
+(ert-deftest todo-test-done-items-separator05-bol ()
+  "Test moving to next item from BOL of done items separator.
+This should move point to the first done todo item."
+  (with-todo-test
+   (todo-test--done-items-separator)
+   (let ((first-done (save-excursion
+                      ;; Move to empty line after last todo item.
+                      (forward-line -1)
+                      (todo-next-item)
+                      (todo-item-string))))
+     (should (string= first-done (save-excursion
+                                  (todo-next-item)
+                                  (todo-item-string)))))))
+
+(ert-deftest todo-test-done-items-separator05-eol ()
+  "Test moving to next item from EOL of done items separator.
+This should move point to the first done todo item."
+  (with-todo-test
+   (todo-test--done-items-separator 'eol)
+   (let ((first-done (save-excursion
+                      ;; Move to empty line after last todo item.
+                      (forward-line -1)
+                      (todo-next-item)
+                      (todo-item-string))))
+     (should (string= first-done (save-excursion
+                                  (todo-next-item)
+                                  (todo-item-string)))))))
+
+;; Item highlighting uses hl-line-mode, which enables highlighting in
+;; post-command-hook.  For some reason, in the test environment, the
+;; hook function is not automatically run, so after enabling item
+;; highlighting, use ert-simulate-command around the next command,
+;; which explicitly runs the hook function.
+(ert-deftest todo-test-done-items-separator06-bol ()
+  "Test enabling item highlighting at BOL of done items separator.
+Subsequently moving to an item should show it highlighted."
+  (with-todo-test
+   (todo-test--done-items-separator)
+   (call-interactively #'todo-toggle-item-highlighting)
+   (ert-simulate-command '(todo-previous-item))
+   (should (eq 'hl-line (get-char-property (point) 'face)))))
+
+(ert-deftest todo-test-done-items-separator06-eol ()
+  "Test enabling item highlighting at EOL of done items separator.
+Subsequently moving to an item should show it highlighted."
+  (with-todo-test
+   (todo-test--done-items-separator 'eol)
+   (todo-toggle-item-highlighting)
+   (forward-line -1)
+   (ert-simulate-command '(todo-previous-item))
+   (should (eq 'hl-line (get-char-property (point) 'face)))))
+
+(ert-deftest todo-test-done-items-separator07 ()
+  "Test item highlighting when crossing done items separator.
+The highlighting should remain enabled."
+  (with-todo-test
+   (todo-test--done-items-separator)
+   (todo-previous-item)
+   (todo-toggle-item-highlighting)
+   (todo-next-item)               ; Now on empty line above separator.
+   (forward-line)                 ; Now on separator.
+   (ert-simulate-command '(forward-line)) ; Now on first done item.
+   (should (eq 'hl-line (get-char-property (point) 'face)))))
+
 
 (provide 'todo-mode-tests)
 ;;; todo-mode-tests.el ends here
diff --git a/test/lisp/emacs-lisp/backtrace-tests.el 
b/test/lisp/emacs-lisp/backtrace-tests.el
new file mode 100644
index 0000000..edd45c7
--- /dev/null
+++ b/test/lisp/emacs-lisp/backtrace-tests.el
@@ -0,0 +1,436 @@
+;;; backtrace-tests.el --- Tests for backtraces -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Gemini Lasswell
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'backtrace)
+(require 'ert)
+(require 'ert-x)
+(require 'seq)
+
+;; Delay evaluation of the backtrace-creating functions until
+;; load so that the backtraces are the same whether this file
+;; is compiled or not.
+
+(eval-and-compile
+  (defconst backtrace-tests--uncompiled-functions
+    '(progn
+       (defun backtrace-tests--make-backtrace (arg)
+         (backtrace-tests--setup-buffer))
+
+       (defun backtrace-tests--setup-buffer ()
+         "Set up the current buffer in backtrace mode."
+         (backtrace-mode)
+         (setq backtrace-frames (backtrace-get-frames))
+         (let ((this-index))
+           ;; Discard all past `backtrace-tests-make-backtrace'.
+           (dotimes (index (length backtrace-frames))
+             (when (eq (backtrace-frame-fun (nth index backtrace-frames))
+                       'backtrace-tests--make-backtrace)
+               (setq this-index index)))
+           (setq backtrace-frames (seq-subseq backtrace-frames 0 (1+ 
this-index))))
+         (backtrace-print))))
+
+  (eval backtrace-tests--uncompiled-functions))
+
+(defun backtrace-tests--backtrace-lines ()
+  (if debugger-stack-frame-as-list
+      '("  (backtrace-get-frames)\n"
+        "  (setq backtrace-frames (backtrace-get-frames))\n"
+        "  (backtrace-tests--setup-buffer)\n"
+        "  (backtrace-tests--make-backtrace %s)\n")
+    '("  backtrace-get-frames()\n"
+      "  (setq backtrace-frames (backtrace-get-frames))\n"
+      "  backtrace-tests--setup-buffer()\n"
+      "  backtrace-tests--make-backtrace(%s)\n")))
+
+(defconst backtrace-tests--line-count (length 
(backtrace-tests--backtrace-lines)))
+
+(defun backtrace-tests--backtrace-lines-with-locals ()
+  (let ((lines (backtrace-tests--backtrace-lines))
+        (locals '("    [no locals]\n"
+                  "    [no locals]\n"
+                  "    [no locals]\n"
+                  "    arg = %s\n")))
+    (apply #'append (cl-mapcar #'list lines locals))))
+
+(defun backtrace-tests--result (value)
+  (format (apply #'concat (backtrace-tests--backtrace-lines))
+          (cl-prin1-to-string value)))
+
+(defun backtrace-tests--result-with-locals (value)
+  (let ((str (cl-prin1-to-string value)))
+    (format (apply #'concat (backtrace-tests--backtrace-lines-with-locals))
+            str str)))
+
+;; TODO check that debugger-batch-max-lines still works
+
+(defconst backtrace-tests--header "Test header\n")
+(defun backtrace-tests--insert-header ()
+  (insert backtrace-tests--header))
+
+;;; Tests
+
+(ert-deftest backtrace-tests--variables ()
+  "Backtrace buffers can show and hide local variables."
+  (ert-with-test-buffer (:name "variables")
+    (let ((results (concat backtrace-tests--header
+                           (backtrace-tests--result 'value)))
+          (last-frame (format (nth (1- backtrace-tests--line-count)
+                                   (backtrace-tests--backtrace-lines)) 'value))
+          (last-frame-with-locals
+           (format (apply #'concat (nthcdr (* 2 (1- 
backtrace-tests--line-count))
+                                           
(backtrace-tests--backtrace-lines-with-locals)))
+                   'value 'value)))
+      (backtrace-tests--make-backtrace 'value)
+      (setq backtrace-insert-header-function #'backtrace-tests--insert-header)
+      (backtrace-print)
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results))
+      ;; Go to the last frame.
+      (goto-char (point-max))
+      (forward-line -1)
+      ;; Turn on locals for that frame.
+      (backtrace-toggle-locals)
+      (should (string= (backtrace-tests--get-substring (point) (point-max))
+                       last-frame-with-locals))
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       (concat results
+                               (format (car (last 
(backtrace-tests--backtrace-lines-with-locals)))
+                                       'value))))
+      ;; Turn off locals for that frame.
+      (backtrace-toggle-locals)
+      (should (string= (backtrace-tests--get-substring (point) (point-max))
+                       last-frame))
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results))
+      ;; Turn all locals on.
+      (backtrace-toggle-locals '(4))
+      (should (string= (backtrace-tests--get-substring (point) (point-max))
+                       last-frame-with-locals))
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       (concat backtrace-tests--header
+                               (backtrace-tests--result-with-locals 'value))))
+      ;; Turn all locals off.
+      (backtrace-toggle-locals '(4))
+      (should (string= (backtrace-tests--get-substring
+                        (point) (+ (point) (length last-frame)))
+                       last-frame))
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results)))))
+
+(ert-deftest backtrace-tests--backward-frame ()
+  "`backtrace-backward-frame' moves backward to the start of a frame."
+  (ert-with-test-buffer (:name "backward")
+    (let ((results (concat backtrace-tests--header
+                           (backtrace-tests--result nil))))
+      (backtrace-tests--make-backtrace nil)
+      (setq backtrace-insert-header-function #'backtrace-tests--insert-header)
+      (backtrace-print)
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results))
+
+      ;; Try to move backward from header.
+      (goto-char (+ (point-min) (/ (length backtrace-tests--header) 2)))
+      (let ((pos (point)))
+        (should-error (backtrace-backward-frame))
+        (should (= pos (point))))
+
+      ;; Try to move backward from start of first line.
+      (forward-line)
+      (let ((pos (point)))
+        (should-error (backtrace-backward-frame))
+        (should (= pos (point))))
+
+      ;; Move backward from middle of line.
+      (let ((start (point)))
+        (forward-char (/ (length (nth 0 (backtrace-tests--backtrace-lines))) 
2))
+        (backtrace-backward-frame)
+        (should (= start (point))))
+
+      ;; Move backward from end of buffer.
+      (goto-char (point-max))
+      (backtrace-backward-frame)
+      (let* ((last (format (car (last (backtrace-tests--backtrace-lines))) 
nil))
+             (len (length last)))
+        (should (string= (buffer-substring-no-properties (point) (+ (point) 
len))
+                         last)))
+
+      ;; Move backward from start of line.
+      (backtrace-backward-frame)
+      (let* ((line (car (last (backtrace-tests--backtrace-lines) 2)))
+             (len (length line)))
+        (should (string= (buffer-substring-no-properties (point) (+ (point) 
len))
+                         line))))))
+
+(ert-deftest backtrace-tests--forward-frame ()
+  "`backtrace-forward-frame' moves forward to the start of a frame."
+  (ert-with-test-buffer (:name "forward")
+    (let* ((arg '(1 2 3))
+           (results (concat backtrace-tests--header
+                            (backtrace-tests--result arg)))
+           (first-line (nth 0 (backtrace-tests--backtrace-lines))))
+      (backtrace-tests--make-backtrace arg)
+      (setq backtrace-insert-header-function #'backtrace-tests--insert-header)
+      (backtrace-print)
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results))
+      ;; Move forward from header.
+      (goto-char (+ (point-min) (/ (length backtrace-tests--header) 2)))
+      (backtrace-forward-frame)
+      (should (string= (backtrace-tests--get-substring
+                        (point) (+ (point) (length first-line)))
+                       first-line))
+
+      (let ((start (point))
+            (offset (/ (length first-line) 2))
+            (second-line (nth 1 (backtrace-tests--backtrace-lines))))
+        ;; Move forward from start of first frame.
+        (backtrace-forward-frame)
+        (should (string= (backtrace-tests--get-substring
+                          (point) (+ (point) (length second-line)))
+                         second-line))
+        ;; Move forward from middle of first frame.
+        (goto-char (+ start offset))
+        (backtrace-forward-frame)
+        (should (string= (backtrace-tests--get-substring
+                          (point) (+ (point) (length second-line)))
+                         second-line)))
+      ;; Try to move forward from middle of last frame.
+      (goto-char (- (point-max)
+                    (/ 2 (length (car (last 
(backtrace-tests--backtrace-lines)))))))
+      (should-error (backtrace-forward-frame))
+      ;; Try to move forward from end of buffer.
+      (goto-char (point-max))
+      (should-error (backtrace-forward-frame)))))
+
+(ert-deftest backtrace-tests--single-and-multi-line ()
+  "Forms in backtrace frames can be on a single line or on multiple lines."
+  (ert-with-test-buffer (:name "single-multi-line")
+    (let* ((arg '(lambda (x)  ; Quote this so it isn't made into a closure.
+                   (let ((number (1+ x)))
+                     (+ x number))))
+           (header-string "Test header: ")
+           (header (format "%s%s\n" header-string arg))
+           (insert-header-function (lambda ()
+                                     (insert header-string)
+                                     (insert (backtrace-print-to-string arg))
+                                     (insert "\n")))
+           (results (concat header (backtrace-tests--result arg)))
+           (last-line (format (nth (1- backtrace-tests--line-count)
+                                   (backtrace-tests--backtrace-lines))
+                              arg))
+           (last-line-locals (format (nth (1- (* 2 
backtrace-tests--line-count))
+                                          
(backtrace-tests--backtrace-lines-with-locals))
+                                     arg)))
+
+      (backtrace-tests--make-backtrace arg)
+      (setq backtrace-insert-header-function insert-header-function)
+      (backtrace-print)
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results))
+      ;; Check pp and collapse for the form in the header.
+      (goto-char (point-min))
+      (backtrace-tests--verify-single-and-multi-line header)
+      ;; Check pp and collapse for the last frame.
+      (goto-char (point-max))
+      (backtrace-backward-frame)
+      (backtrace-tests--verify-single-and-multi-line last-line)
+      ;; Check pp and collapse for local variables in the last line.
+      (goto-char (point-max))
+      (backtrace-backward-frame)
+      (backtrace-toggle-locals)
+      (forward-line)
+      (backtrace-tests--verify-single-and-multi-line last-line-locals))))
+
+(defun backtrace-tests--verify-single-and-multi-line (line)
+  "Verify that `backtrace-single-line' and `backtrace-multi-line' work at 
point.
+Point should be at the beginning of a line, and LINE should be a
+string containing the text of the line at point.  Assume that the
+line contains the strings \"lambda\" and \"number\"."
+  (let ((pos (point)))
+    (backtrace-multi-line)
+    ;; Verify point is still at the start of the line.
+    (should (= pos (point))))
+
+  ;; Verify the form now spans multiple lines.
+  (let ((pos (point)))
+    (search-forward "number")
+    (should-not (= pos (point-at-bol))))
+  ;; Collapse the form.
+  (backtrace-single-line)
+  ;; Verify that the form is now back on one line,
+  ;; and that point is at the same place.
+  (should (string= (backtrace-tests--get-substring
+                    (- (point) 6) (point)) "number"))
+  (should-not (= (point) (point-at-bol)))
+  (should (string= (backtrace-tests--get-substring
+                    (point-at-bol) (1+ (point-at-eol)))
+                   line)))
+
+(ert-deftest backtrace-tests--print-circle ()
+  "Backtrace buffers can toggle `print-circle' syntax."
+  (ert-with-test-buffer (:name "print-circle")
+    (let* ((print-circle nil)
+           (arg (let ((val (make-list 5 'a))) (nconc val val) val))
+           (results (backtrace-tests--make-regexp
+                     (backtrace-tests--result arg)))
+           (results-circle (regexp-quote (let ((print-circle t))
+                                           (backtrace-tests--result arg))))
+           (last-frame (backtrace-tests--make-regexp
+                        (format (nth (1- backtrace-tests--line-count)
+                                     (backtrace-tests--backtrace-lines))
+                                arg)))
+           (last-frame-circle (regexp-quote
+                               (let ((print-circle t))
+                                 (format (nth (1- backtrace-tests--line-count)
+                                              
(backtrace-tests--backtrace-lines))
+                                         arg)))))
+      (backtrace-tests--make-backtrace arg)
+      (backtrace-print)
+      (should (string-match-p results
+                              (backtrace-tests--get-substring (point-min) 
(point-max))))
+      ;; Go to the last frame.
+      (goto-char (point-max))
+      (forward-line -1)
+      ;; Turn on print-circle for that frame.
+      (backtrace-toggle-print-circle)
+      (should (string-match-p last-frame-circle
+                              (backtrace-tests--get-substring (point) 
(point-max))))
+      ;; Turn off print-circle for the frame.
+      (backtrace-toggle-print-circle)
+      (should (string-match-p last-frame
+                              (backtrace-tests--get-substring (point) 
(point-max))))
+      (should (string-match-p results
+                              (backtrace-tests--get-substring (point-min) 
(point-max))))
+      ;; Turn print-circle on for the buffer.
+      (backtrace-toggle-print-circle '(4))
+      (should (string-match-p last-frame-circle
+                              (backtrace-tests--get-substring (point) 
(point-max))))
+      (should (string-match-p results-circle
+                              (backtrace-tests--get-substring (point-min) 
(point-max))))
+      ;; Turn print-circle off.
+      (backtrace-toggle-print-circle '(4))
+      (should (string-match-p last-frame
+                              (backtrace-tests--get-substring
+                               (point) (+ (point) (length last-frame)))))
+      (should (string-match-p results
+                              (backtrace-tests--get-substring (point-min) 
(point-max)))))))
+
+(defun backtrace-tests--make-regexp (str)
+  "Make regexp from STR for `backtrace-tests--print-circle'.
+Used for results of printing circular objects without
+`print-circle' on.  Look for #n in string STR where n is any
+digit and replace with #[0-9]."
+  (let ((regexp (regexp-quote str)))
+    (with-temp-buffer
+      (insert regexp)
+      (goto-char (point-min))
+      (while (re-search-forward "#[0-9]" nil t)
+        (replace-match "#[0-9]")))
+    (buffer-string)))
+
+(ert-deftest backtrace-tests--expand-ellipsis ()
+  "Backtrace buffers ellipsify large forms as buttons which expand the 
ellipses."
+  ;; make a backtrace with an ellipsis
+  ;; expand the ellipsis
+  (ert-with-test-buffer (:name "variables")
+    (let* ((print-level nil)
+           (print-length nil)
+           (backtrace-line-length 300)
+           (arg (make-list 40 (make-string 10 ?a)))
+           (results (backtrace-tests--result arg)))
+      (backtrace-tests--make-backtrace arg)
+      (backtrace-print)
+
+      ;; There should be an ellipsis. Find and expand it.
+      (goto-char (point-min))
+      (search-forward "...")
+      (backward-char)
+      (push-button)
+
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results)))))
+
+(ert-deftest backtrace-tests--expand-ellipses ()
+  "Backtrace buffers ellipsify large forms and can expand the ellipses."
+  (ert-with-test-buffer (:name "variables")
+    (let* ((print-level nil)
+           (print-length nil)
+           (backtrace-line-length 300)
+           (arg (let ((outer (make-list 40 (make-string 10 ?a)))
+                      (nested (make-list 40 (make-string 10 ?b))))
+                  (setf (nth 39 nested) (make-list 40 (make-string 10 ?c)))
+                  (setf (nth 39 outer) nested)
+                  outer))
+           (results (backtrace-tests--result-with-locals arg)))
+
+      ;; Make a backtrace with local variables visible.
+      (backtrace-tests--make-backtrace arg)
+      (backtrace-print)
+      (backtrace-toggle-locals '(4))
+
+      ;; There should be two ellipses.
+      (goto-char (point-min))
+      (should (search-forward "..."))
+      (should (search-forward "..."))
+      (should-error (search-forward "..."))
+
+      ;; Expanding the last frame without argument should expand both
+      ;; ellipses, but the expansions will contain one ellipsis each.
+      (let ((buffer-len (- (point-max) (point-min))))
+        (goto-char (point-max))
+        (backtrace-backward-frame)
+        (backtrace-expand-ellipses)
+        (should (> (- (point-max) (point-min)) buffer-len))
+        (goto-char (point-min))
+        (should (search-forward "..."))
+        (should (search-forward "..."))
+        (should-error (search-forward "...")))
+
+      ;; Expanding with argument should remove all ellipses.
+      (goto-char (point-max))
+      (backtrace-backward-frame)
+      (backtrace-expand-ellipses '(4))
+      (goto-char (point-min))
+
+      (should-error (search-forward "..."))
+      (should (string= (backtrace-tests--get-substring (point-min) (point-max))
+                       results)))))
+
+
+(ert-deftest backtrace-tests--to-string ()
+  "Backtraces can be produced as strings."
+  (let ((frames (ert-with-test-buffer (:name nil)
+                  (backtrace-tests--make-backtrace "string")
+                  backtrace-frames)))
+    (should (string= (backtrace-to-string frames)
+                     (backtrace-tests--result "string")))))
+
+(defun backtrace-tests--get-substring (beg end)
+  "Return the visible text between BEG and END.
+Strip the string properties because it makes failed test results
+easier to read."
+  (substring-no-properties (filter-buffer-substring beg end)))
+
+(provide 'backtrace-tests)
+
+;;; backtrace-tests.el ends here
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el 
b/test/lisp/emacs-lisp/cl-print-tests.el
index 404d323..a469b55 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -56,19 +56,30 @@
   (let ((long-list (make-list 5 'a))
         (long-vec (make-vector 5 'b))
         (long-struct (cl-print-tests-con))
+        (long-string (make-string 5 ?a))
         (print-length 4))
     (should (equal "(a a a a ...)" (cl-prin1-to-string long-list)))
     (should (equal "[b b b b ...]" (cl-prin1-to-string long-vec)))
     (should (equal "#s(cl-print-tests-struct :a nil :b nil :c nil :d nil ...)"
-                   (cl-prin1-to-string long-struct)))))
+                   (cl-prin1-to-string long-struct)))
+    (should (equal "\"aaaa...\"" (cl-prin1-to-string long-string)))))
 
 (ert-deftest cl-print-tests-4 ()
   "CL printing observes `print-level'."
-  (let ((deep-list '(a (b (c (d (e))))))
-        (deep-struct (cl-print-tests-con))
-        (print-level 4))
+  (let* ((deep-list '(a (b (c (d (e))))))
+         (buried-vector '(a (b (c (d [e])))))
+         (deep-struct (cl-print-tests-con))
+         (buried-struct `(a (b (c (d ,deep-struct)))))
+         (buried-string '(a (b (c (d #("hello" 0 5 (cl-print-test t)))))))
+         (buried-simple-string '(a (b (c (d "hello")))))
+         (print-level 4))
     (setf (cl-print-tests-struct-a deep-struct) deep-list)
     (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string deep-list)))
+    (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string buried-vector)))
+    (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string buried-struct)))
+    (should (equal "(a (b (c (d ...))))" (cl-prin1-to-string buried-string)))
+    (should (equal "(a (b (c (d \"hello\"))))"
+                   (cl-prin1-to-string buried-simple-string)))
     (should (equal "#s(cl-print-tests-struct :a (a (b (c ...))) :b nil :c nil 
:d nil :e nil)"
                    (cl-prin1-to-string deep-struct)))))
 
@@ -82,6 +93,129 @@
       (should (equal "((quote a) (function b) (\\` ((\\, c) (\\,@ d))))"
                      (cl-prin1-to-string quoted-stuff))))))
 
+(ert-deftest cl-print-tests-strings ()
+  "CL printing prints strings and propertized strings."
+  (let* ((str1 "abcdefghij")
+         (str2 #("abcdefghij" 3 6 (bold t) 7 9 (italic t)))
+         (str3 #("abcdefghij" 0 10 (test t)))
+         (obj '(a b))
+         ;; Since the byte compiler reuses string literals,
+         ;; and the put-text-property call is destructive, use
+         ;; copy-sequence to make a new string.
+         (str4 (copy-sequence "abcdefghij")))
+    (put-text-property 0 5 'test obj str4)
+    (put-text-property 7 10 'test obj str4)
+
+    (should (equal "\"abcdefghij\"" (cl-prin1-to-string str1)))
+    (should (equal "#(\"abcdefghij\" 3 6 (bold t) 7 9 (italic t))"
+                   (cl-prin1-to-string str2)))
+    (should (equal "#(\"abcdefghij\" 0 10 (test t))"
+                   (cl-prin1-to-string str3)))
+    (let ((print-circle nil))
+      (should
+       (equal
+        "#(\"abcdefghij\" 0 5 (test (a b)) 7 10 (test (a b)))"
+        (cl-prin1-to-string str4))))
+    (let ((print-circle t))
+      (should
+       (equal
+        "#(\"abcdefghij\" 0 5 (test #1=(a b)) 7 10 (test #1#))"
+        (cl-prin1-to-string str4))))))
+
+(ert-deftest cl-print-tests-ellipsis-cons ()
+  "Ellipsis expansion works in conses."
+  (let ((print-length 4)
+        (print-level 3))
+    (cl-print-tests-check-ellipsis-expansion
+     '(0 1 2 3 4 5) "(0 1 2 3 ...)" "4 5")
+    (cl-print-tests-check-ellipsis-expansion
+     '(0 1 2 3 4 5 6 7 8 9) "(0 1 2 3 ...)" "4 5 6 7 ...")
+    (cl-print-tests-check-ellipsis-expansion
+     '(a (b (c (d (e))))) "(a (b (c ...)))" "(d (e))")
+    (cl-print-tests-check-ellipsis-expansion
+     (let ((x (make-list 6 'b)))
+       (setf (nthcdr 6 x) 'c)
+       x)
+     "(b b b b ...)" "b b . c")))
+
+(ert-deftest cl-print-tests-ellipsis-vector ()
+  "Ellipsis expansion works in vectors."
+  (let ((print-length 4)
+        (print-level 3))
+    (cl-print-tests-check-ellipsis-expansion
+     [0 1 2 3 4 5] "[0 1 2 3 ...]" "4 5")
+    (cl-print-tests-check-ellipsis-expansion
+     [0 1 2 3 4 5 6 7 8 9] "[0 1 2 3 ...]" "4 5 6 7 ...")
+    (cl-print-tests-check-ellipsis-expansion
+     [a [b [c [d [e]]]]] "[a [b [c ...]]]" "[d [e]]")))
+
+(ert-deftest cl-print-tests-ellipsis-string ()
+  "Ellipsis expansion works in strings."
+  (let ((print-length 4)
+        (print-level 3))
+    (cl-print-tests-check-ellipsis-expansion
+     "abcdefg" "\"abcd...\"" "efg")
+    (cl-print-tests-check-ellipsis-expansion
+     "abcdefghijk" "\"abcd...\"" "efgh...")
+    (cl-print-tests-check-ellipsis-expansion
+     '(1 (2 (3 #("abcde" 0 5 (test t)))))
+     "(1 (2 (3 ...)))" "#(\"abcd...\" 0 5 (test t))")
+    (cl-print-tests-check-ellipsis-expansion
+     #("abcd" 0 1 (bold t) 1 2 (invisible t) 3 4 (italic t))
+     "#(\"abcd\" 0 1 (bold t) ...)" "1 2 (invisible t) ...")))
+
+(ert-deftest cl-print-tests-ellipsis-struct ()
+  "Ellipsis expansion works in structures."
+  (let ((print-length 4)
+        (print-level 3)
+        (struct (cl-print-tests-con)))
+    (cl-print-tests-check-ellipsis-expansion
+     struct "#s(cl-print-tests-struct :a nil :b nil :c nil :d nil ...)" ":e 
nil")
+    (let ((print-length 2))
+      (cl-print-tests-check-ellipsis-expansion
+       struct "#s(cl-print-tests-struct :a nil :b nil ...)" ":c nil :d nil 
..."))
+    (cl-print-tests-check-ellipsis-expansion
+     `(a (b (c ,struct)))
+     "(a (b (c ...)))"
+     "#s(cl-print-tests-struct :a nil :b nil :c nil :d nil ...)")))
+
+(ert-deftest cl-print-tests-ellipsis-circular ()
+  "Ellipsis expansion works with circular objects."
+  (let ((wide-obj (list 0 1 2 3 4))
+        (deep-obj `(0 (1 (2 (3 (4))))))
+        (print-length 4)
+        (print-level 3))
+    (setf (nth 4 wide-obj) wide-obj)
+    (setf (car (cadadr (cadadr deep-obj))) deep-obj)
+    (let ((print-circle nil))
+      (cl-print-tests-check-ellipsis-expansion-rx
+       wide-obj (regexp-quote "(0 1 2 3 ...)") "\\`#[0-9]\\'")
+      (cl-print-tests-check-ellipsis-expansion-rx
+       deep-obj (regexp-quote "(0 (1 (2 ...)))") "\\`(3 (#[0-9]))\\'"))
+    (let ((print-circle t))
+      (cl-print-tests-check-ellipsis-expansion
+       wide-obj "#1=(0 1 2 3 ...)" "#1#")
+      (cl-print-tests-check-ellipsis-expansion
+       deep-obj "#1=(0 (1 (2 ...)))" "(3 (#1#))"))))
+
+(defun cl-print-tests-check-ellipsis-expansion (obj expected expanded)
+  (let* ((result (cl-prin1-to-string obj))
+         (pos (next-single-property-change 0 'cl-print-ellipsis result))
+         value)
+    (should pos)
+    (setq value (get-text-property pos 'cl-print-ellipsis result))
+    (should (equal expected result))
+    (should (equal expanded (with-output-to-string (cl-print-expand-ellipsis
+                                                    value nil))))))
+
+(defun cl-print-tests-check-ellipsis-expansion-rx (obj expected expanded)
+  (let* ((result (cl-prin1-to-string obj))
+         (pos (next-single-property-change 0 'cl-print-ellipsis result))
+         (value (get-text-property pos 'cl-print-ellipsis result)))
+    (should (string-match expected result))
+    (should (string-match expanded (with-output-to-string
+                                     (cl-print-expand-ellipsis value nil))))))
+
 (ert-deftest cl-print-circle ()
   (let ((x '(#1=(a . #1#) #1#)))
     (let ((print-circle nil))
@@ -99,5 +233,41 @@
     (let ((print-circle t))
       (should (equal "(0 . #1=(0 . #1#))" (cl-prin1-to-string x))))))
 
+(ert-deftest cl-print-tests-print-to-string-with-limit ()
+  (let* ((thing10 (make-list 10 'a))
+         (thing100 (make-list 100 'a))
+         (thing10x10 (make-list 10 thing10))
+         (nested-thing (let ((val 'a))
+                         (dotimes (_i 20)
+                           (setq val (list val)))
+                         val))
+         ;; Make a consistent environment for this test.
+         (print-circle nil)
+         (print-level nil)
+         (print-length nil))
+
+    ;; Print something that fits in the space given.
+    (should (string= (cl-prin1-to-string thing10)
+                     (cl-print-to-string-with-limit #'cl-prin1 thing10 100)))
+
+    ;; Print something which needs to be abbreviated and which can be.
+    (should (< (length (cl-print-to-string-with-limit #'cl-prin1 thing100 100))
+               100
+               (length (cl-prin1-to-string thing100))))
+
+    ;; Print something resistant to easy abbreviation.
+    (should (string= (cl-prin1-to-string thing10x10)
+                     (cl-print-to-string-with-limit #'cl-prin1 thing10x10 
100)))
+
+    ;; Print something which should be abbreviated even if the limit is large.
+    (should (< (length (cl-print-to-string-with-limit #'cl-prin1 nested-thing 
1000))
+               (length (cl-prin1-to-string nested-thing))))
+
+    ;; Print with no limits.
+    (dolist (thing (list thing10 thing100 thing10x10 nested-thing))
+      (let ((rep (cl-prin1-to-string thing)))
+        (should (string= rep (cl-print-to-string-with-limit #'cl-prin1 thing 
0)))
+        (should (string= rep (cl-print-to-string-with-limit #'cl-prin1 thing 
nil)))))))
+
 
 ;;; cl-print-tests.el ends here.
diff --git a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el 
b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
index e86c2f1..97dead0 100644
--- a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
+++ b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
@@ -41,7 +41,7 @@
 (defun edebug-test-code-range (num)
   !start!(let ((index 0)
         (result nil))
-    (while (< index num)!test!
+    (while !lt!(< index num)!test!
       (push index result)!loop!
       (cl-incf index))!end-loop!
     (nreverse result)))
@@ -130,5 +130,12 @@
   (let ((two 2) (three 3))
     (cl-destructuring-bind (x . y) (cons two three) (+ x!x! y!y!))))
 
+(defun edebug-test-code-use-cl-macrolet (x)
+  (cl-macrolet ((wrap (func &rest args)
+                     `(format "The result of applying %s to %s is %S"
+                               ',func!func! ',args
+                               ,(cons func args))))
+    (wrap + 1 x)))
+
 (provide 'edebug-test-code)
 ;;; edebug-test-code.el ends here
diff --git a/test/lisp/emacs-lisp/edebug-tests.el 
b/test/lisp/emacs-lisp/edebug-tests.el
index 85f6bd4..7880aaf 100644
--- a/test/lisp/emacs-lisp/edebug-tests.el
+++ b/test/lisp/emacs-lisp/edebug-tests.el
@@ -432,9 +432,11 @@ test and possibly others should be updated."
     (verify-keybinding "P" 'edebug-view-outside) ;; same as v
     (verify-keybinding "W" 'edebug-toggle-save-windows)
     (verify-keybinding "?" 'edebug-help)
-    (verify-keybinding "d" 'edebug-backtrace)
+    (verify-keybinding "d" 'edebug-pop-to-backtrace)
     (verify-keybinding "-" 'negative-argument)
-    (verify-keybinding "=" 'edebug-temp-display-freq-count)))
+    (verify-keybinding "=" 'edebug-temp-display-freq-count)
+    (should (eq (lookup-key backtrace-mode-map "n") 'backtrace-forward-frame))
+    (should (eq (lookup-key backtrace-mode-map "s") 'backtrace-goto-source))))
 
 (ert-deftest edebug-tests-stop-point-at-start-of-first-instrumented-function ()
   "Edebug stops at the beginning of an instrumented function."
@@ -913,5 +915,28 @@ test and possibly others should be updated."
     "g"
     (should (equal address@hidden 5)))))
 
+(ert-deftest edebug-tests-cl-macrolet ()
+  "Edebug can instrument `cl-macrolet' expressions. (Bug#29919)"
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "use-cl-macrolet" '(10) t)
+   (edebug-tests-run-kbd-macro
+    "@ SPC SPC"
+    (edebug-tests-should-be-at "use-cl-macrolet" "func")
+    (edebug-tests-should-match-result-in-messages "+")
+    "g"
+    (should (equal address@hidden "The result of applying + to (1 x) is 
11")))))
+
+(ert-deftest edebug-tests-backtrace-goto-source ()
+  "Edebug can jump to instrumented source from its *Edebug-Backtrace* buffer."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "range" '(2) t)
+   (edebug-tests-run-kbd-macro
+    "@ SPC SPC"
+    (edebug-tests-should-be-at "range" "lt")
+    "dns"  ; Pop to backtrace, next frame, goto source.
+    (edebug-tests-should-be-at "range" "start")
+    "g"
+    (should (equal address@hidden '(0 1))))))
+
 (provide 'edebug-tests)
 ;;; edebug-tests.el ends here
diff --git a/test/lisp/emacs-lisp/ert-tests.el 
b/test/lisp/emacs-lisp/ert-tests.el
index cb957bd..1fe5b79 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -376,7 +376,7 @@ This macro is used to test if macroexpansion in `should' 
works."
          (test (make-ert-test :body test-body))
          (result (ert-run-test test)))
     (should (ert-test-failed-p result))
-    (should (eq (nth 1 (car (ert-test-failed-backtrace result)))
+    (should (eq (backtrace-frame-fun (car (ert-test-failed-backtrace result)))
                 'signal))))
 
 (ert-deftest ert-test-messages ()
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el 
b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 8598d41..30f606d 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -113,6 +113,29 @@ noindent\" 3
       ;; we're indenting ends on the previous line.
       (should (equal (buffer-string) original)))))
 
+(ert-deftest indent-sexp-go ()
+  "Make sure `indent-sexp' doesn't stop after #s."
+  ;; See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31984.
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "#s(foo\nbar)\n")
+    (goto-char (point-min))
+    (indent-sexp)
+    (should (equal (buffer-string) "\
+#s(foo
+   bar)\n"))))
+
+(ert-deftest indent-sexp-cant-go ()
+  "`indent-sexp' shouldn't error before a sexp."
+  ;; See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31984#32.
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "(())")
+    (goto-char (1+ (point-min)))
+    ;; Paredit calls `indent-sexp' from this position.
+    (indent-sexp)
+    (should (equal (buffer-string) "(())"))))
+
 (ert-deftest lisp-indent-region ()
   "Test basics of `lisp-indent-region'."
   (with-temp-buffer
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 56403f4..612ea8c 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -891,9 +891,9 @@ delivered."
 
            ;; Modify file.  We wait for two seconds, in order to
            ;; have another timestamp.  One second seems to be too
-            ;; short.
+            ;; short.  And Cygwin sporadically requires more than two.
             (ert-with-message-capture captured-messages
-              (sleep-for 2)
+              (sleep-for (if (eq system-type 'cygwin) 3 2))
               (write-region
                "foo bla" nil file-notify--test-tmpfile nil 'no-message)
 
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index f3e97b5..29a8df8 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2182,7 +2182,7 @@ This checks also `file-name-as-directory', 
`file-name-directory',
          (unwind-protect
              ;; FIXME: This fails on my QNAP server, see
              ;; /share/Web/owncloud/data/owncloud.log
-             (unless (tramp--test-owncloud-p)
+             (unless (tramp--test-nextcloud-p)
                (write-region "foo" nil source)
                (should (file-exists-p source))
                (make-directory target)
@@ -2205,7 +2205,7 @@ This checks also `file-name-as-directory', 
`file-name-directory',
          (unwind-protect
              ;; FIXME: This fails on my QNAP server, see
              ;; /share/Web/owncloud/data/owncloud.log
-             (unless (and (tramp--test-owncloud-p)
+             (unless (and (tramp--test-nextcloud-p)
                           (or (not (file-remote-p source))
                               (not (file-remote-p target))))
                (make-directory source)
@@ -2231,7 +2231,7 @@ This checks also `file-name-as-directory', 
`file-name-directory',
              ;; FIXME: This fails on my QNAP server, see
              ;; /share/Web/owncloud/data/owncloud.log
              (unless
-                 (and (tramp--test-owncloud-p) (not (file-remote-p source)))
+                 (and (tramp--test-nextcloud-p) (not (file-remote-p source)))
                (make-directory source)
                (should (file-directory-p source))
                (write-region "foo" nil (expand-file-name "foo" source))
@@ -2320,7 +2320,7 @@ This checks also `file-name-as-directory', 
`file-name-directory',
          (unwind-protect
              ;; FIXME: This fails on my QNAP server, see
              ;; /share/Web/owncloud/data/owncloud.log
-             (unless (tramp--test-owncloud-p)
+             (unless (tramp--test-nextcloud-p)
                (make-directory source)
                (should (file-directory-p source))
                (write-region "foo" nil (expand-file-name "foo" source))
@@ -2344,7 +2344,7 @@ This checks also `file-name-as-directory', 
`file-name-directory',
          (unwind-protect
              ;; FIXME: This fails on my QNAP server, see
              ;; /share/Web/owncloud/data/owncloud.log
-             (unless (tramp--test-owncloud-p)
+             (unless (tramp--test-nextcloud-p)
                (make-directory source)
                (should (file-directory-p source))
                (write-region "foo" nil (expand-file-name "foo" source))
@@ -4427,10 +4427,10 @@ This does not support external Emacs calls."
   (string-equal
    "mock" (file-remote-p tramp-test-temporary-file-directory 'method)))
 
-(defun tramp--test-owncloud-p ()
-  "Check, whether the owncloud method is used."
+(defun tramp--test-nextcloud-p ()
+  "Check, whether the nextcloud method is used."
   (string-equal
-   "owncloud" (file-remote-p tramp-test-temporary-file-directory 'method)))
+   "nextcloud" (file-remote-p tramp-test-temporary-file-directory 'method)))
 
 (defun tramp--test-rsync-p ()
   "Check, whether the rsync method is used.
diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el
index 5ded944..085ab47 100644
--- a/test/lisp/shadowfile-tests.el
+++ b/test/lisp/shadowfile-tests.el
@@ -15,10 +15,22 @@
 ;; General Public License for more details.
 ;;
 ;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see `http://www.gnu.org/licenses/'.
+;; along with this program.  If not, see `https://www.gnu.org/licenses/'.
 
 ;;; Commentary:
 
+;; Some of the tests require access to a remote host files.  Since
+;; this could be problematic, a mock-up connection method "mock" is
+;; used.  Emulating a remote connection, it simply calls "sh -i".
+;; Tramp's file name handlers still run, so this test is sufficient
+;; except for connection establishing.
+
+;; If you want to test a real Tramp connection, set
+;; $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable value in order to
+;; overwrite the default value.  If you want to skip tests accessing a
+;; remote host, set this environment variable to "/dev/null" or
+;; whatever is appropriate on your system.
+
 ;; A whole test run can be performed calling the command `shadowfile-test-all'.
 
 ;;; Code:
@@ -64,6 +76,7 @@
 Per definition, all files are identical on the different hosts of
 a cluster (or site).  This is not tested here; it must be
 guaranteed by the originator of a cluster definition."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
   (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
 
   (let ((text-quoting-style 'grave) ;; We inspect the *Messages* buffer!
@@ -187,6 +200,7 @@ guaranteed by the originator of a cluster definition."
 Per definition, all files are identical on the different hosts of
 a cluster (or site).  This is not tested here; it must be
 guaranteed by the originator of a cluster definition."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
   (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
 
   (let ((shadow-info-file shadow-test-info-file)
@@ -293,6 +307,7 @@ guaranteed by the originator of a cluster definition."
 
 (ert-deftest shadow-test02-files ()
   "Check file manipulation functions."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
   (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
 
   (let ((shadow-info-file shadow-test-info-file)
@@ -368,6 +383,7 @@ guaranteed by the originator of a cluster definition."
 
 (ert-deftest shadow-test03-expand-cluster-in-file-name ()
   "Check canonical file name of a cluster or site."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
   (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
 
   (let ((shadow-info-file shadow-test-info-file)
@@ -438,6 +454,7 @@ guaranteed by the originator of a cluster definition."
 
 (ert-deftest shadow-test04-contract-file-name ()
   "Check canonical file name of a cluster or site."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
   (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
 
   (let ((shadow-info-file shadow-test-info-file)
@@ -498,6 +515,7 @@ guaranteed by the originator of a cluster definition."
 
 (ert-deftest shadow-test05-file-match ()
   "Check `shadow-same-site' and `shadow-file-match'."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
   (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
 
   (let ((shadow-info-file shadow-test-info-file)
@@ -556,6 +574,9 @@ guaranteed by the originator of a cluster definition."
 
 (ert-deftest shadow-test06-literal-groups ()
   "Check literal group definitions."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
+  (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
+
   (let ((shadow-info-file shadow-test-info-file)
        (shadow-todo-file shadow-test-todo-file)
        shadow-clusters shadow-literal-groups
@@ -618,6 +639,9 @@ guaranteed by the originator of a cluster definition."
 
 (ert-deftest shadow-test07-regexp-groups ()
   "Check regexp group definitions."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
+  (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
+
   (let ((shadow-info-file shadow-test-info-file)
        (shadow-todo-file shadow-test-todo-file)
        shadow-clusters shadow-regexp-groups
@@ -682,6 +706,10 @@ guaranteed by the originator of a cluster definition."
 
 (ert-deftest shadow-test08-shadow-todo ()
   "Check that needed shadows are added to todo."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
+  (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
+  (skip-unless (file-writable-p shadow-test-remote-temporary-file-directory))
+
   (let ((backup-inhibited t)
         (shadow-info-file shadow-test-info-file)
        (shadow-todo-file shadow-test-todo-file)
@@ -690,6 +718,7 @@ guaranteed by the originator of a cluster definition."
         shadow-files-to-copy
        cluster1 cluster2 primary regexp file)
     (unwind-protect
+        (condition-case err
         (progn
          ;; Cleanup.
          (when (file-exists-p shadow-info-file)
@@ -697,6 +726,7 @@ guaranteed by the originator of a cluster definition."
          (when (file-exists-p shadow-todo-file)
            (delete-file shadow-todo-file))
 
+          (message "Point 1")
           ;; Define clusters.
          (setq cluster1 "cluster1"
                primary shadow-system-name
@@ -709,6 +739,7 @@ guaranteed by the originator of a cluster definition."
                regexp (shadow-regexp-superquote primary))
          (shadow-set-cluster cluster2 primary regexp)
 
+          (message "Point 2")
          ;; Define a literal group.
          (setq file
                (make-temp-name
@@ -716,21 +747,35 @@ guaranteed by the originator of a cluster definition."
                 shadow-literal-groups
                 `((,(concat "/cluster1:" file) ,(concat "/cluster2:" file))))
 
+          (message "Point 3")
           ;; Save file from "cluster1" definition.
           (with-temp-buffer
             (setq buffer-file-name file)
             (insert "foo")
             (save-buffer))
+          (message "%s" file)
+          (message "%s" (shadow-contract-file-name (concat "/cluster2:" file)))
+          (message "%s" shadow-files-to-copy)
          (should
            (member
             (cons file (shadow-contract-file-name (concat "/cluster2:" file)))
             shadow-files-to-copy))
 
+          (message "Point 4")
           ;; Save file from "cluster2" definition.
           (with-temp-buffer
+            (message "Point 4.1")
+            (message "%s" file)
+            (message "%s" (shadow-site-primary cluster2))
             (setq buffer-file-name (concat (shadow-site-primary cluster2) 
file))
+            (message "Point 4.2")
             (insert "foo")
+            (message "%s" buffer-file-name)
             (save-buffer))
+          (message "Point 4.3")
+          (message "%s" (shadow-site-primary cluster2))
+          (message "%s" (shadow-contract-file-name (concat "/cluster1:" file)))
+          (message "%s" shadow-files-to-copy)
          (should
            (member
             (cons
@@ -738,6 +783,7 @@ guaranteed by the originator of a cluster definition."
              (shadow-contract-file-name (concat "/cluster1:" file)))
             shadow-files-to-copy))
 
+          (message "Point 5")
          ;; Define a regexp group.
          (setq shadow-files-to-copy nil
                 shadow-regexp-groups
@@ -746,6 +792,7 @@ guaranteed by the originator of a cluster definition."
                    ,(concat (shadow-site-primary cluster2)
                             (shadow-regexp-superquote file)))))
 
+          (message "Point 6")
           ;; Save file from "cluster1" definition.
           (with-temp-buffer
             (setq buffer-file-name file)
@@ -756,6 +803,7 @@ guaranteed by the originator of a cluster definition."
             (cons file (shadow-contract-file-name (concat "/cluster2:" file)))
             shadow-files-to-copy))
 
+          (message "Point 7")
           ;; Save file from "cluster2" definition.
           (with-temp-buffer
             (setq buffer-file-name (concat (shadow-site-primary cluster2) 
file))
@@ -767,19 +815,25 @@ guaranteed by the originator of a cluster definition."
              (concat (shadow-site-primary cluster2) file)
              (shadow-contract-file-name (concat "/cluster1:" file)))
             shadow-files-to-copy)))
+        (error (message "Error: %s" err) (signal (car err) (cdr err))))
 
       ;; Cleanup.
       (when (file-exists-p shadow-info-file)
        (delete-file shadow-info-file))
       (when (file-exists-p shadow-todo-file)
        (delete-file shadow-todo-file))
-      (when (file-exists-p file)
-       (delete-file file))
-      (when (file-exists-p (concat (shadow-site-primary cluster2) file))
-       (delete-file (concat (shadow-site-primary cluster2) file))))))
+      (ignore-errors
+        (when (file-exists-p file)
+         (delete-file file)))
+      (ignore-errors
+        (when (file-exists-p (concat (shadow-site-primary cluster2) file))
+         (delete-file (concat (shadow-site-primary cluster2) file)))))))
 
 (ert-deftest shadow-test09-shadow-copy-files ()
   "Check that needed shadow files are copied."
+  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
+  (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory))
+
   (let ((backup-inhibited t)
         (shadow-info-file shadow-test-info-file)
        (shadow-todo-file shadow-test-todo-file)
@@ -856,10 +910,12 @@ guaranteed by the originator of a cluster definition."
        (delete-file shadow-info-file))
       (when (file-exists-p shadow-todo-file)
        (delete-file shadow-todo-file))
-      (when (file-exists-p file)
-       (delete-file file))
-      (when (file-exists-p (concat (shadow-site-primary cluster2) file))
-       (delete-file (concat (shadow-site-primary cluster2) file))))))
+      (ignore-errors
+        (when (file-exists-p file)
+         (delete-file file)))
+      (ignore-errors
+        (when (file-exists-p (concat (shadow-site-primary cluster2) file))
+         (delete-file (concat (shadow-site-primary cluster2) file)))))))
 
 (defun shadowfile-test-all (&optional interactive)
   "Run all tests for \\[shadowfile]."
diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el
new file mode 100644
index 0000000..b4ef4ab
--- /dev/null
+++ b/test/lisp/wdired-tests.el
@@ -0,0 +1,129 @@
+;;; wdired-tests.el --- tests for wdired.el          -*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'dired)
+(require 'wdired)
+
+(defvar dired-query)                    ; Pacify byte compiler.
+
+(ert-deftest wdired-test-bug32173-01 ()
+  "Test using non-nil wdired-use-interactive-rename.
+Partially modifying a file name should succeed."
+  (let* ((test-dir (make-temp-file "test-dir-" t))
+        (test-file (concat (file-name-as-directory test-dir) "foo.c"))
+        (replace "bar")
+        (new-file (replace-regexp-in-string "foo" replace test-file))
+        (wdired-use-interactive-rename t))
+    (write-region "" nil test-file nil 'silent)
+    (advice-add 'dired-query ; Don't ask confirmation to overwrite a file.
+                :override
+                (lambda (_sym _prompt &rest _args) (setq dired-query t))
+                '((name . "advice-dired-query")))
+    (let ((buf (find-file-noselect test-dir)))
+      (unwind-protect
+         (with-current-buffer buf
+           (should (equal (dired-file-name-at-point) test-file))
+           (dired-toggle-read-only)
+           (kill-region (point) (progn (search-forward ".")
+                                       (forward-char -1) (point)))
+           (insert replace)
+           (wdired-finish-edit)
+           (should (equal (dired-file-name-at-point) new-file)))
+       (if buf (kill-buffer buf))
+       (delete-directory test-dir t)))))
+
+(ert-deftest wdired-test-bug32173-02 ()
+  "Test using non-nil wdired-use-interactive-rename.
+Aborting an edit should leaving original file name unchanged."
+  (let* ((test-dir (make-temp-file "test-dir-" t))
+        (test-file (concat (file-name-as-directory test-dir) "foo.c"))
+        (wdired-use-interactive-rename t))
+    (write-region "" nil test-file nil 'silent)
+    ;; Make dired-do-create-files-regexp a noop to mimic typing C-g
+    ;; at its prompt before wdired-finish-edit returns.
+    (advice-add 'dired-do-create-files-regexp
+                :override
+                (lambda (&rest _) (ignore))
+                '((name . "advice-dired-do-create-files-regexp")))
+    (let ((buf (find-file-noselect test-dir)))
+      (unwind-protect
+         (with-current-buffer buf
+           (should (equal (dired-file-name-at-point) test-file))
+           (dired-toggle-read-only)
+           (kill-region (point) (progn (search-forward ".")
+                                       (forward-char -1) (point)))
+           (insert "bar")
+           (wdired-finish-edit)
+           (should (equal (dired-get-filename) test-file)))
+       (if buf (kill-buffer buf))
+       (delete-directory test-dir t)))))
+
+(ert-deftest wdired-test-symlink-name ()
+  "Test the file name of a symbolic link.
+The Dired and WDired functions returning the name should include
+only the name before the link arrow."
+  (let* ((test-dir (make-temp-file "test-dir-" t))
+         (link-name "foo"))
+    (let ((buf (find-file-noselect test-dir)))
+      (unwind-protect
+         (with-current-buffer buf
+            (make-symbolic-link "./bar/baz" link-name)
+            (revert-buffer)
+            (let* ((file-name (dired-get-filename))
+                   (dir-part (file-name-directory file-name))
+                   (lf-name (concat dir-part link-name)))
+             (should (equal file-name lf-name))
+             (dired-toggle-read-only)
+             (should (equal (wdired-get-filename) lf-name))
+             (dired-toggle-read-only)))
+       (if buf (kill-buffer buf))
+       (delete-directory test-dir t)))))
+
+(ert-deftest wdired-test-unfinished-edit-01 ()
+  "Test editing a file name without saving the change.
+Finding the new name should be possible while still in
+wdired-mode."
+  :expected-result (if (< emacs-major-version 27) :failed :passed)
+  (let* ((test-dir (make-temp-file "test-dir-" t))
+        (test-file (concat (file-name-as-directory test-dir) "foo.c"))
+        (replace "bar")
+        (new-file (replace-regexp-in-string "foo" replace test-file)))
+    (write-region "" nil test-file nil 'silent)
+    (let ((buf (find-file-noselect test-dir)))
+      (unwind-protect
+         (with-current-buffer buf
+           (should (equal (dired-file-name-at-point) test-file))
+           (dired-toggle-read-only)
+           (kill-region (point) (progn (search-forward ".")
+                                       (forward-char -1) (point)))
+           (insert replace)
+           (should (equal (dired-get-filename) new-file))))
+       (when buf
+         (with-current-buffer buf
+            ;; Prevent kill-buffer-query-functions from chiming in.
+           (set-buffer-modified-p nil)
+           (kill-buffer buf)))
+       (delete-directory test-dir t))))
+
+
+(provide 'wdired-tests)
+;;; wdired-tests.el ends here
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index c828000..2951270 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -165,10 +165,12 @@
                 :type 'overflow-error)
   (should-error (read (substring (format "%d" most-negative-fixnum) 1))
                 :type 'overflow-error)
-  (should-error (read (format "#x%x" most-negative-fixnum))
-                :type 'overflow-error)
-  (should-error (read (format "#o%o" most-negative-fixnum))
-                :type 'overflow-error)
+  (let ((binary-as-unsigned nil))
+    (dolist (fmt '("%d" "%s" "#o%o" "#x%x"))
+      (dolist (val (list most-negative-fixnum (1+ most-negative-fixnum)
+                         -1 0 1
+                         (1- most-positive-fixnum) most-positive-fixnum))
+        (should (eq val (read (format fmt val)))))))
   (should-error (read (format "#32rG%x" most-positive-fixnum))
                 :type 'overflow-error))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]