emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master abcb2e6 6/7: Merge from origin/emacs-26


From: Paul Eggert
Subject: [Emacs-diffs] master abcb2e6 6/7: Merge from origin/emacs-26
Date: Mon, 25 Sep 2017 14:22:11 -0400 (EDT)

branch: master
commit abcb2e62dae6aa26308f7ac9efc89247f89cbe65
Merge: 0bd61c2 49cd561
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Merge from origin/emacs-26
    
    49cd561dc6 * test/lisp/tramp-tests.el (tramp-test21-file-links): Spec...
    b719f6b20b Loosen strict parsing requirement for desktop files
    c7a0c13777 * lisp/xdg.el (xdg-thumb-uri): Fix doc string.
    dc6b3560e5 Fix documentation of `make-frame' and related variables an...
    3d3778d82a Accept new `always' value for option `buffer-offer-save'
    638f64c40a Improve new NS scrolling variable names
    d93301242f Document 'replace-buffer-contents' in the manual.
    00e4e3e9d2 Fix undecorated frame resizing issues on NS (bug#28512)
    820739bbb5 ; * doc/emacs/display.texi (Display Custom): Fix wording.
    f2b2201594 ; Spelling and URL fixes
    0e143b1fc5 Documentation improvements for 'display-line-numbers'
    f656ccdb43 ; Fix typo
    d64da52d57 Fix last change in bat-mode.el
    908af46abd Fix restoring in GUI sessions desktop saved in TTY sessions
    51cbd85454 Improve syntax highlighting in bat-mode
    0273916618 Document the 'list-FOO' convention
    d24ec58540 Expose viewing conditions in CAM02-UCS metric
    a81d5a3d3f Revert "Set frame size to actual requested size (bug#18215)"
    0bf066d4b2 Add tests for Edebug
    68baca3ee1 Catch more messages in ert-with-message-capture
    28e0c410c9 ; * lisp/mouse.el (secondary-selection-exist-p): Doc fix.
    31e1d9ef2f Support setting region from secondary selection and vice v...
    047f02f00f Fix new copy-directory bug with empty dirs
    fbd15836af * doc/lispref/strings.texi (Formatting Strings): Improve i...
    f16a8d5dbd Fix 2 testsuite tests for MS-Windows
    965cffd89c Rename timer-list to list-timers
    a5fec62b51 Provide native touchpad scrolling on macOS
    7b3d1c6beb Fix MinGW64 build broken by recent MinGW64 import libraries
    c83d0c5fdf Fix crashes in 'move-point-visually' in minibuffer windows
    7f3d5f929d * src/emacs.c (usage_message): Don't mention 'find-file'.
    6845282200 Fix a minor inaccuracy in the Emacs manual
    74d7bb9498 Fix errors in flyspell-post-command-hook
    40fdbb01d0 Work on Tramp's file-truename
    1a01423b3c Fix bug with make-directory on MS-Windows root
    066efb8666 Fix log-view-diff-common when point is after last entry
    3f006b56cd Adapt fileio-tests--symlink-failure to Cygwin
    ee512e9a82 Ignore buffers whose name begins with a space in save-some...
    9e1b5bd92c Improve tramp-interrupt-process robustness
    8d4223e61b Minor Tramp doc update
    331d0e520f Fix gensym
    466df76f7d Cleanup in files-tests.el
    6359fe630a Remove old cl-assert calls in 'newline'
    059184e645 Avoid crash with C-g C-g in GC
    541006c536 Fix format-time-string %Z bug with negative tz
    679e05eeb9 message-citation-line-format %Z is now tz name
    4e8888d438 Use doc-view or pdf-tools on any window-system
    5f28f0db73 Fix bug with min and max and NaNs
    37b5e661d2 Fix recently-introduced copy-directory bug
    6bbbc38b34 Merge from Gnulib
    57249fb297 Fix compatibility problem in Tramp
    411bec82c4 Avoid GCC 7 compilation warning in eval.c
    34a6774daa ; Partially revert c3445aed5194
---
 ChangeLog.2                                        |   4 +-
 ChangeLog.3                                        |   8 +-
 build-aux/config.guess                             |  38 +-
 build-aux/config.sub                               |  20 +-
 build-aux/gitlog-to-changelog                      |   2 +-
 configure.ac                                       |   8 +-
 doc/emacs/anti.texi                                |   2 +-
 doc/emacs/cmdargs.texi                             |  10 +-
 doc/emacs/display.texi                             |  15 +-
 doc/lispref/buffers.texi                           |  15 +-
 doc/lispref/files.texi                             |   8 +-
 doc/lispref/frames.texi                            |  58 +-
 doc/lispref/os.texi                                |   4 +-
 doc/lispref/strings.texi                           |   5 +-
 doc/lispref/text.texi                              |  24 +
 doc/lispref/tips.texi                              |  11 +-
 doc/misc/texinfo.tex                               |  14 +-
 doc/misc/tramp.texi                                |   8 +
 lib/allocator.h                                    |   2 +-
 lib/count-leading-zeros.h                          |   3 +-
 lib/count-trailing-zeros.h                         |   3 +-
 lib/dup2.c                                         |   2 +-
 lib/filevercmp.c                                   |   2 +-
 lib/fstatat.c                                      |   2 +-
 lib/fsync.c                                        |   4 +-
 lib/ftoastr.c                                      |   2 +-
 lib/ftoastr.h                                      |   2 +-
 lib/gnulib.mk.in                                   |   1 +
 lib/intprops.h                                     |   6 +-
 lib/signal.in.h                                    |   2 +-
 lib/stdio-impl.h                                   |  10 +-
 lib/stdio.in.h                                     |   4 +-
 lib/unistd.in.h                                    |   4 +-
 lib/utimens.c                                      |  10 +-
 lisp/calendar/cal-tex.el                           |   2 +-
 lisp/emacs-lisp/ert-x.el                           |  57 +-
 lisp/emacs-lisp/subr-x.el                          |   2 +-
 lisp/emacs-lisp/timer-list.el                      |   6 +-
 lisp/files.el                                      |  42 +-
 lisp/frame.el                                      |  20 +-
 lisp/frameset.el                                   |  13 +-
 lisp/gnus/message.el                               |   1 -
 lisp/mouse.el                                      |  28 +
 lisp/mwheel.el                                     |   1 +
 lisp/net/mailcap.el                                |   6 +-
 lisp/net/tramp-adb.el                              |   2 +-
 lisp/net/tramp-compat.el                           |  33 +-
 lisp/net/tramp-sh.el                               |  28 +-
 lisp/net/tramp-smb.el                              |  10 +-
 lisp/net/tramp.el                                  |  33 +-
 lisp/org/ChangeLog.1                               |   4 +-
 lisp/progmodes/bat-mode.el                         |   6 +-
 lisp/simple.el                                     |  39 +-
 lisp/subr.el                                       |   7 +-
 lisp/term/ns-win.el                                |  19 +
 lisp/textmodes/ispell.el                           |   6 +-
 lisp/vc/log-view.el                                |  14 +-
 lisp/xdg.el                                        |   4 +-
 m4/alloca.m4                                       |   4 +-
 m4/extern-inline.m4                                |   8 +-
 m4/fstatat.m4                                      |   2 +-
 m4/gnulib-common.m4                                |   6 +-
 m4/manywarnings.m4                                 |  17 +-
 m4/std-gnu11.m4                                    |   4 +-
 m4/sys_types_h.m4                                  |   2 +-
 m4/vararrays.m4                                    |   2 +-
 src/Makefile.in                                    |   2 +-
 src/data.c                                         |  12 +-
 src/editfns.c                                      |   3 +-
 src/emacs.c                                        |   8 +-
 src/eval.c                                         |   2 +-
 src/keyboard.c                                     |   5 +-
 src/lcms.c                                         | 107 ++-
 src/nsterm.m                                       | 173 +++-
 src/term.c                                         |  12 +-
 src/termhooks.h                                    |   4 +-
 src/xdisp.c                                        |   4 +-
 .../edebug-resources/edebug-test-code.el           | 130 +++
 test/lisp/emacs-lisp/edebug-tests.el               | 903 +++++++++++++++++++++
 test/lisp/files-tests.el                           |  20 +-
 test/lisp/ibuffer-tests.el                         |  51 +-
 test/lisp/net/tramp-tests.el                       |  22 +-
 test/lisp/subr-tests.el                            |   6 +
 test/lisp/vc/smerge-mode-tests.el                  |   2 +-
 test/lisp/xdg-tests.el                             |   3 -
 test/src/data-tests.el                             |   6 +-
 test/src/editfns-tests.el                          |   8 +
 test/src/fileio-tests.el                           |   2 +
 test/src/lcms-tests.el                             |  37 +-
 89 files changed, 1861 insertions(+), 402 deletions(-)

diff --git a/ChangeLog.2 b/ChangeLog.2
index bd1800b..e789722 100644
--- a/ChangeLog.2
+++ b/ChangeLog.2
@@ -4808,7 +4808,7 @@
        Link from (emacs)Exiting to (lisp)Killing Emacs
 
        * doc/emacs/entering.texi (Exiting): Link to the lispref
-       manual for further customisations (bug#15445).
+       manual for further customizations (bug#15445).
 
        (cherry picked from commit bc5f27aa099cdde02ca66e71501b89300685ab28)
 
@@ -7845,7 +7845,7 @@
 
 2016-02-20  Lars Ingebrigtsen  <address@hidden>
 
-       Allow customising the article mode cursor behavior
+       Allow customizing the article mode cursor behavior
 
        * doc/misc/gnus.texi (HTML): Mention gnus-article-show-cursor.
 
diff --git a/ChangeLog.3 b/ChangeLog.3
index 9f43511..9e622ce 100644
--- a/ChangeLog.3
+++ b/ChangeLog.3
@@ -12949,7 +12949,7 @@
        Link from (emacs)Exiting to (lisp)Killing Emacs
 
        * doc/emacs/entering.texi (Exiting): Link to the lispref
-       manual for further customisations (bug#15445).
+       manual for further customizations (bug#15445).
 
 2016-04-29  Lars Ingebrigtsen  <address@hidden>
 
@@ -13159,7 +13159,7 @@
        Move the diff command to "Operate" in ibuffer
 
        * lisp/ibuffer.el (ibuffer-mode-operate-map): Move the diff
-       command to the "Operate" menu, and remove the customisation
+       command to the "Operate" menu, and remove the customization
        entry to make the "View" menu more logical (bug#1150).
 
 2016-04-27  Lars Ingebrigtsen  <address@hidden>
@@ -16589,7 +16589,7 @@
        really changed.
        (save_window_save): Set the pixel_height_before_size_change and
        pixel_width_before_size_change fields.
-       (Vwindow_size_change_functions): Move here definiton from xdisp.c.
+       (Vwindow_size_change_functions): Move here definition from xdisp.c.
        * src/xdisp.c (prepare_menu_bars, redisplay_internal): Call
        run_window_size_change_functions.
        (Vwindow_size_change_functions): Move definition to window.c.
@@ -16842,7 +16842,7 @@
        5d17ae7 Improve file-notify-test08-watched-file-in-watched-dir
        1cb1268 Fix todo-mode item date editing bugs
        1e996cf Fix "[:upper:]" for non-ASCII characters
-       896f993 Allow customising the article mode cursor behavior
+       896f993 Allow customizing the article mode cursor behavior
        24c1c1d Use pop-to-buffer-same-window in woman.el
        2a75f64 New filenotify test for bug#22736
        c9bccf7 Report critical battery errors
diff --git a/build-aux/config.guess b/build-aux/config.guess
index a744844..8bd1095 100755
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2017 Free Software Foundation, Inc.
 
-timestamp='2017-08-08'
+timestamp='2017-09-16'
 
 # 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
@@ -15,7 +15,7 @@ timestamp='2017-08-08'
 # 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/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -27,7 +27,7 @@ timestamp='2017-08-08'
 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 #
 # Please send patches to <address@hidden>.
 
@@ -318,15 +318,6 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        exitcode=$?
        trap '' 0
        exit $exitcode ;;
-    Alpha\ *:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # Should we change UNAME_MACHINE based on the output of uname instead
-       # of the specific Alpha model?
-       echo alpha-pc-interix
-       exit ;;
-    21064:Windows_NT:50:3)
-       echo alpha-dec-winnt3.5
-       exit ;;
     Amiga*:UNIX_System_V:4.0:*)
        echo m68k-unknown-sysv4
        exit ;;
@@ -858,10 +849,6 @@ EOF
     *:MSYS*:*)
        echo ${UNAME_MACHINE}-pc-msys
        exit ;;
-    i*:windows32*:*)
-       # uname -m includes "-pc" on this system.
-       echo ${UNAME_MACHINE}-mingw32
-       exit ;;
     i*:PW*:*)
        echo ${UNAME_MACHINE}-pc-pw32
        exit ;;
@@ -877,27 +864,12 @@ EOF
                echo ia64-unknown-interix${UNAME_RELEASE}
                exit ;;
        esac ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-       echo i${UNAME_MACHINE}-pc-mks
-       exit ;;
-    8664:Windows_NT:*)
-       echo x86_64-pc-mks
-       exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-       # UNAME_MACHINE based on the output of uname instead of i386?
-       echo i586-pc-interix
-       exit ;;
     i*:UWIN*:*)
        echo ${UNAME_MACHINE}-pc-uwin
        exit ;;
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
        echo x86_64-unknown-cygwin
        exit ;;
-    p*:CYGWIN*:*)
-       echo powerpcle-unknown-cygwin
-       exit ;;
     prep*:SunOS:5.*:*)
        echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 
's/[^.]*//'`
        exit ;;
@@ -1435,9 +1407,9 @@ This script (version $timestamp), has failed to recognize 
the
 operating system you are using. If your script is old, overwrite *all*
 copies of config.guess and config.sub with the latest versions from:
 
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 If $0 has already been updated, send the following data and any
 information you think might be pertinent to address@hidden to
diff --git a/build-aux/config.sub b/build-aux/config.sub
index 40ea5df..95dc3d0 100755
--- a/build-aux/config.sub
+++ b/build-aux/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2017 Free Software Foundation, Inc.
 
-timestamp='2017-04-02'
+timestamp='2017-09-16'
 
 # 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
@@ -15,7 +15,7 @@ timestamp='2017-04-02'
 # 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/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -33,7 +33,7 @@ timestamp='2017-04-02'
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
@@ -229,9 +229,6 @@ case $os in
        -ptx*)
                basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
                ;;
-       -windowsnt*)
-               os=`echo $os | sed -e 's/windowsnt/winnt/'`
-               ;;
        -psos*)
                os=-psos
                ;;
@@ -1259,6 +1256,9 @@ case $basic_machine in
                basic_machine=hppa1.1-winbond
                os=-proelf
                ;;
+       x64)
+               basic_machine=x86_64-pc
+               ;;
        xbox)
                basic_machine=i686-pc
                os=-mingw32
@@ -1366,8 +1366,8 @@ esac
 if [ x"$os" != x"" ]
 then
 case $os in
-       # First match some system type aliases
-       # that might get confused with valid system types.
+       # First match some system type aliases that might get confused
+       # with valid system types.
        # -solaris* is a basic system type, with this one exception.
        -auroraux)
                os=-auroraux
@@ -1387,9 +1387,9 @@ case $os in
        -gnu/linux*)
                os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
                ;;
-       # First accept the basic system types.
+       # Now accept the basic system types.
        # The portable systems comes first.
-       # Each alternative MUST END IN A *, to match a version number.
+       # Each alternative MUST end in a * to match a version number.
        # -sysv* is not here because it comes later, after sysvr4.
        -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
              | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | 
-sunos[34]*\
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index ec5ab9e..3c94bd5 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -33,7 +33,7 @@ use POSIX qw(strftime);
 
 (my $ME = $0) =~ s|.*/||;
 
-# use File::Coda; # http://meyering.net/code/Coda/
+# use File::Coda; # https://meyering.net/code/Coda/
 END {
   defined fileno STDOUT or return;
   close STDOUT and return;
diff --git a/configure.ac b/configure.ac
index 35b7e69..75bda7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2077,15 +2077,15 @@ if test "${HAVE_W32}" = "yes"; then
   AC_SUBST(comma_space_version)
   AC_CONFIG_FILES([nt/emacs.rc nt/emacsclient.rc])
   if test "${opsys}" = "cygwin"; then
-    W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
-    W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
+    W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lusp10 -lgdi32"
+    W32_LIBS="$W32_LIBS -lole32 -lcomdlg32 -lcomctl32 -lwinspool"
     # Tell the linker that emacs.res is an object (which we compile from
     # the rc file), not a linker script.
     W32_RES_LINK="-Wl,emacs.res"
   else
     W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
-    W32_LIBS="$W32_LIBS -lwinmm -lgdi32 -lcomdlg32"
-    W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32 -lusp10"
+    W32_LIBS="$W32_LIBS -lwinmm -lusp10 -lgdi32 -lcomdlg32"
+    W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32"
     W32_RES_LINK="\$(EMACSRES)"
     CLIENTRES="emacsclient.res"
     CLIENTW="emacsclientw\$(EXEEXT)"
diff --git a/doc/emacs/anti.texi b/doc/emacs/anti.texi
index ffec915..547dbd1 100644
--- a/doc/emacs/anti.texi
+++ b/doc/emacs/anti.texi
@@ -94,7 +94,7 @@ happen.  The variables 
@code{'attempt-stack-overflow-recovery} and
 @code{attempt-orderly-shutdown-on-fatal-signal} are therefore removed.
 
 @item
-The @code{timer-list} command was removed, as we decided timers are
+The @code{list-timers} command was removed, as we decided timers are
 not user-level feature, and therefore users should not be allowed to
 mess with them.  Ask an Emacs Lisp guru near you for help if you have
 a runaway timer in your session.  (Of course, as you move back in
diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi
index 819459e..618a05d 100644
--- a/doc/emacs/cmdargs.texi
+++ b/doc/emacs/cmdargs.texi
@@ -92,7 +92,7 @@ arguments.)
 @itemx address@hidden
 @cindex visiting files, command-line argument
 @vindex inhibit-startup-buffer-menu
-Visit @var{file} using @code{find-file}.  @xref{Visiting}.
+Visit the specified @var{file}.  @xref{Visiting}.
 
 When Emacs starts up, it displays the startup buffer in one window,
 and the buffer visiting @var{file} in another window
@@ -111,12 +111,12 @@ Buffer Menu for this, change the variable
 
 @item address@hidden @var{file}
 @opindex address@hidden
-Visit @var{file} using @code{find-file}, then go to line number
address@hidden in it.
+Visit the specified @var{file}, then go to line number @var{linenum}
+in it.
 
 @item address@hidden:@var{columnnum} @var{file}
-Visit @var{file} using @code{find-file}, then go to line number
address@hidden and put point at column number @var{columnnum}.
+Visit the specified @var{file}, then go to line number @var{linenum}
+and put point at column number @var{columnnum}.
 
 @item -l @var{file}
 @opindex -l
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 2aa79e1..6afd836 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1745,7 +1745,7 @@ invisible parts of text), and lines which wrap to consume 
more than
 one screen line will be numbered that many times.  The displayed
 numbers are relative, as with @code{relative} value above.  This is
 handy in modes that fold text, such as Outline mode (@pxref{Outline
-Mode}), and need to move by exact number of screen lines.
+Mode}), and when you need to move by exact number of screen lines.
 
 @item anything else
 Any other address@hidden value is treated as @code{t}.
@@ -1756,7 +1756,7 @@ Any other address@hidden value is treated as @code{t}.
 @vindex display-line-numbers-type
 A convenient way of turning on display of line numbers is @address@hidden
 display-line-numbers-mode @key{RET}}}.  This mode has a globalized
-variant, @code{global-display-line0numbers-mode}.  The user option
+variant, @code{global-display-line-numbers-mode}.  The user option
 @code{display-line-numbers-type} controls which sub-mode of
 line-number display, described above, will these modes activate.
 
@@ -1778,6 +1778,17 @@ the variable @code{display-line-numbers-widen} to a 
address@hidden
 value, line numbers will disregard any narrowing and will start at the
 first character of the buffer.
 
address@hidden display-line-numbers-width-start
address@hidden display-line-numbers-grow-only
address@hidden display-line-numbers-width
+In selective display mode (@pxref{Selective Display}), and other modes
+that hide many lines from display (such as Outline and Org modes), you
+may wish to customize the variables
address@hidden and
address@hidden, or set
address@hidden to a large enough value, to avoid
+occasional miscalculations of space reserved for the line numbers.
+
 @cindex line-number face
 The line numbers are displayed in a special face @code{line-number}.
 The current line number is displayed in a different face,
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index cf24a73..0d02cb3 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -1089,12 +1089,15 @@ is not cleared by changing major modes.
 
 @defopt buffer-offer-save
 This variable, if address@hidden in a particular buffer, tells
address@hidden and @code{save-some-buffers} (if the
-second optional argument to that function is @code{t}) to offer to
-save that buffer, just as they offer to save file-visiting buffers.
address@hidden of save-some-buffers}.  The variable
address@hidden automatically becomes buffer-local when set
-for any reason.  @xref{Buffer-Local Variables}.
address@hidden to offer to save that buffer, just as
+it offers to save file-visiting buffers.  If @code{save-some-buffers}
+is called with the second optional argument set to @code{t}, it will
+also offer to save the buffer.  Lastly, if this variable is set to the
+symbol @code{always}, both @code{save-buffers-kill-emacs} and
address@hidden will always offer to save.  @xref{Definition
+of save-some-buffers}.  The variable @code{buffer-offer-save}
+automatically becomes buffer-local when set for any reason.
address@hidden Variables}.
 @end defopt
 
 @defvar buffer-save-without-query
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index e4a4bfe..0a37eeb 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -332,7 +332,9 @@ in the list @code{find-file-hook}.
 that is visiting that file---that is, the contents of the file are
 copied into the buffer and the copy is what you edit.  Changes to the
 buffer do not change the file until you @dfn{save} the buffer, which
-means copying the contents of the buffer into the file.
+means copying the contents of the buffer into the file.  Buffers which
+are not visiting a file can still be ``saved'', in a sense, using
+functions in the buffer-local @code{write-contents-functions} hook.
 
 @deffn Command save-buffer &optional backup-option
 This function saves the contents of the current buffer in its visited
@@ -365,8 +367,8 @@ With an argument of 0, unconditionally do @emph{not} make 
any backup file.
 @anchor{Definition of save-some-buffers}
 This command saves some modified file-visiting buffers.  Normally it
 asks the user about each buffer.  But if @var{save-silently-p} is
address@hidden, it saves all the file-visiting buffers without querying
-the user.
address@hidden, it saves all the file-visiting buffers without
+querying the user.
 
 @vindex save-some-buffers-default-predicate
 The optional @var{pred} argument provides a predicate that controls
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 6431bbd..f66ecee 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -112,37 +112,39 @@ window of another Emacs frame.  @xref{Child Frames}.
 * Display Feature Testing::     Determining the features of a terminal.
 @end menu
 
+
 @node Creating Frames
 @section Creating Frames
 @cindex frame creation
 
 To create a new frame, call the function @code{make-frame}.
 
address@hidden Command make-frame &optional alist
address@hidden Command make-frame &optional parameters
 This function creates and returns a new frame, displaying the current
 buffer.
 
-The @var{alist} argument is an alist that specifies frame parameters
-for the new frame.  @xref{Frame Parameters}.  If you specify the
address@hidden parameter in @var{alist}, the new frame is created on
-that terminal.  Otherwise, if you specify the @code{window-system}
-frame parameter in @var{alist}, that determines whether the frame
-should be displayed on a text terminal or a graphical terminal.
address@hidden Systems}.  If neither is specified, the new frame is
-created in the same terminal as the selected frame.
-
-Any parameters not mentioned in @var{alist} default to the values in
-the alist @code{default-frame-alist} (@pxref{Initial Parameters});
+The @var{parameters} argument is an alist that specifies frame
+parameters for the new frame.  @xref{Frame Parameters}.  If you specify
+the @code{terminal} parameter in @var{parameters}, the new frame is
+created on that terminal.  Otherwise, if you specify the
address@hidden frame parameter in @var{parameters}, that
+determines whether the frame should be displayed on a text terminal or a
+graphical terminal.  @xref{Window Systems}.  If neither is specified,
+the new frame is created in the same terminal as the selected frame.
+
+Any parameters not mentioned in @var{parameters} default to the values
+in the alist @code{default-frame-alist} (@pxref{Initial Parameters});
 parameters not specified there default from the X resources or its
 equivalent on your operating system (@pxref{X Resources,, X Resources,
-emacs, The GNU Emacs Manual}).  After the frame is created, Emacs
-applies any parameters listed in @code{frame-inherited-parameters}
-(see below) and not present in the argument, taking the values from
-the frame that was selected when @code{make-frame} was called.
+emacs, The GNU Emacs Manual}).  After the frame is created, this
+function applies any parameters specified in
address@hidden (see below) it has no assigned yet,
+taking the values from the frame that was selected when
address@hidden was called.
 
 Note that on multi-monitor displays (@pxref{Multiple Terminals}), the
 window manager might position the frame differently than specified by
-the positional parameters in @var{alist} (@pxref{Position
+the positional parameters in @var{parameters} (@pxref{Position
 Parameters}).  For example, some window managers have a policy of
 displaying the frame on the monitor that contains the largest part of
 the window (a.k.a.@: the @dfn{dominating} monitor).
@@ -158,20 +160,28 @@ A normal hook run by @code{make-frame} before it creates 
the frame.
 @end defvar
 
 @defvar after-make-frame-functions
-An abnormal hook run by @code{make-frame} after it creates the frame.
-Each function in @code{after-make-frame-functions} receives one argument, the
-frame just created.
+An abnormal hook run by @code{make-frame} after it created the frame.
+Each function in @code{after-make-frame-functions} receives one
+argument, the frame just created.
 @end defvar
 
+Note that any functions added to these hooks by your initial file are
+usually not run for the initial frame, since Emacs reads the initial
+file only after creating that frame.  However, if the initial frame is
+specified to use a separate minibuffer frame (@pxref{Minibuffers and
+Frames}), the functions will be run for both, the minibuffer-less and
+the minibuffer frame.
+
 @defvar frame-inherited-parameters
 This variable specifies the list of frame parameters that a newly
 created frame inherits from the currently selected frame.  For each
-parameter (a symbol) that is an element in the list and is not present
-in the argument to @code{make-frame}, the function sets the value of
-that parameter in the created frame to its value in the selected
-frame.
+parameter (a symbol) that is an element in this list and has not been
+assigned earlier when processing @code{make-frame}, the function sets
+the value of that parameter in the created frame to its value in the
+selected frame.
 @end defvar
 
+
 @node Multiple Terminals
 @section Multiple Terminals
 @cindex multiple terminals
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 441fda5..af646ce 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1885,8 +1885,8 @@ one of these functions; the arrival of the specified time 
will not
 cause anything special to happen.
 @end defun
 
address@hidden timer-list
-The @code{timer-list} command lists all the currently active timers.
address@hidden list-timers
+The @code{list-timers} command lists all the currently active timers.
 There's only one command available in the buffer displayed: @kbd{c}
 (@code{timer-list-cancel}) that will cancel the timer on the line
 under point.
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 23961f9..219225d 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -824,8 +824,9 @@ to the produced string representations of the argument 
@var{objects}.
 @end defun
 
 @defun format-message string &rest objects
address@hidden curved quotes
address@hidden curly quotes
address@hidden curved quotes, in formatted messages
address@hidden curly quotes, in formatted messages
address@hidden @code{text-quoting-style}, and formatting messages
 This function acts like @code{format}, except it also converts any
 grave accents (@t{`}) and apostrophes (@t{'}) in @var{string} as per the
 value of @code{text-quoting-style}.
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index a7d1079..baa3c70 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -54,6 +54,8 @@ the character after point.
 * Registers::        How registers are implemented.  Accessing the text or
                        position stored in a register.
 * Transposition::    Swapping two portions of a buffer.
+* Replacing::        Replacing the text of one buffer with the text
+                       of another buffer.
 * Decompression::    Dealing with compressed data.
 * Base 64::          Conversion to or from base 64 encoding.
 * Checksum/Hash::    Computing cryptographic hashes.
@@ -4328,6 +4330,28 @@ is address@hidden, @code{transpose-regions} does not do 
this---it leaves
 all markers unrelocated.
 @end defun
 
address@hidden Replacing
address@hidden Replacing Buffer Text
+
+  You can use the following function to replace the text of one buffer
+with the text of another buffer:
+
address@hidden Command replace-buffer-contents source
+This function replaces the accessible portion of the current buffer
+with the accessible portion of the buffer @var{source}.  @var{source}
+may either be a buffer object or the name of a buffer.  When
address@hidden succeeds, the text of the accessible
+portion of the current buffer will be equal to the text of the
+accessible portion of the @var{source} buffer.  This function attempts
+to keep point, markers, text properties, and overlays in the current
+buffer intact.  One potential case where this behavior is useful is
+external code formatting programs: they typically write the
+reformatted text into a temporary buffer or file, and using
address@hidden and @code{insert-buffer-substring} would destroy
+these properties.  However, the latter combination is typically
+faster.  @xref{Deletion}, and @ref{Insertion}.
address@hidden deffn
+
 @node Decompression
 @section Dealing With Compressed Data
 
diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi
index bed3bed..17fd4a1 100644
--- a/doc/lispref/tips.texi
+++ b/doc/lispref/tips.texi
@@ -68,10 +68,13 @@ costs.}.  Use two hyphens to separate prefix and name if 
the symbol is
 not meant to be used by other packages.
 
 Occasionally, for a command name intended for users to use, it is more
-convenient if some words come before the package's name prefix.  And
-constructs that define functions, variables, etc., work better if they
-start with @samp{defun} or @samp{defvar}, so put the name prefix later
-on in the name.
+convenient if some words come before the package's name prefix.  For
+example, it is our convention to have commands that list objects named
+as @address@hidden, e.g., a package called @samp{frob}
+could have a command @samp{list-frobs}, when its other global symbols
+begin with @samp{frob-}.  Also, constructs that define functions,
+variables, etc., work better if they start with @samp{defun} or
address@hidden, so put the name prefix later on in the name.
 
 This recommendation applies even to names for traditional Lisp
 primitives that are not primitives in Emacs Lisp---such as
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex
index a774790..9bd75b9 100644
--- a/doc/misc/texinfo.tex
+++ b/doc/misc/texinfo.tex
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2017-08-23.19}
+\def\texinfoversion{2017-09-16.10}
 %
 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -21,7 +21,7 @@
 % 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/>.
 %
 % As a special exception, when this file is read by TeX when processing
 % a Texinfo source document, you may use the result without
@@ -30,9 +30,9 @@
 %
 % Please try the latest version of texinfo.tex before submitting bug
 % reports; you can get the latest version from:
-%   http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
-%   http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
-%   http://www.gnu.org/software/texinfo/ (the Texinfo home page)
+%   https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
+%   https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
+%   https://www.gnu.org/software/texinfo/ (the Texinfo home page)
 % The texinfo.tex in any given distribution could well be out
 % of date, so if that's what you're using, please check.
 %
@@ -56,7 +56,7 @@
 % extent.  You can get the existing language-specific files from the
 % full Texinfo distribution.
 %
-% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
+% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
 
 
 \message{Loading texinfo [version \texinfoversion]:}
@@ -9446,7 +9446,7 @@ end
 \newif\ifwarnednoepsf
 \newhelp\noepsfhelp{epsf.tex must be installed for images to
   work.  It is also included in the Texinfo distribution, or you can get
-  it from ftp://tug.org/tex/epsf.tex.}
+  it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
 %
 \def\image#1{%
   \ifx\epsfbox\thisisundefined
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 7e8ce75..6478479 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3043,6 +3043,14 @@ Disable version control to avoid delays:
 @end group
 @end lisp
 
+If this is too radical, because you want to use version control
+remotely, trim @code{vc-handled-backends} to just those you care
+about, for example:
+
address@hidden
+(setq vc-handled-backends '(SVN Git))
address@hidden lisp
+
 Disable excessive traces.  Set @code{tramp-verbose} to 3 or lower,
 default being 3.  Increase trace levels temporarily when hunting for
 bugs.
diff --git a/lib/allocator.h b/lib/allocator.h
index 2ecbf1a..8f79d74 100644
--- a/lib/allocator.h
+++ b/lib/allocator.h
@@ -29,7 +29,7 @@ struct allocator
   /* Do not use GCC attributes such as __attribute__ ((malloc)) with
      the function types pointed at by these members, because these
      attributes do not work with pointers to functions.  See
-     <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00007.html>.  */
+     <https://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00007.html>.  */
 
   /* Call ALLOCATE to allocate memory, like 'malloc'.  On failure ALLOCATE
      should return NULL, though not necessarily set errno.  When given
diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h
index 1b60e28..c8b3dc0 100644
--- a/lib/count-leading-zeros.h
+++ b/lib/count-leading-zeros.h
@@ -70,7 +70,8 @@ _GL_INLINE_HEADER_BEGIN
 COUNT_LEADING_ZEROS_INLINE int
 count_leading_zeros_32 (unsigned int x)
 {
-  /* http://graphics.stanford.edu/~seander/bithacks.html */
+  /* <https://github.com/gibsjose/BitHacks>
+     <http://www.fit.vutbr.cz/~ibarina/pub/bithacks.pdf> */
   static const char de_Bruijn_lookup[32] = {
     31, 22, 30, 21, 18, 10, 29, 2, 20, 17, 15, 13, 9, 6, 28, 1,
     23, 19, 11, 3, 16, 14, 7, 24, 12, 4, 8, 25, 5, 26, 27, 0
diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h
index be71314..9f9f07f 100644
--- a/lib/count-trailing-zeros.h
+++ b/lib/count-trailing-zeros.h
@@ -68,7 +68,8 @@ _GL_INLINE_HEADER_BEGIN
 COUNT_TRAILING_ZEROS_INLINE int
 count_trailing_zeros_32 (unsigned int x)
 {
-  /* http://graphics.stanford.edu/~seander/bithacks.html */
+  /* <https://github.com/gibsjose/BitHacks>
+     <http://www.fit.vutbr.cz/~ibarina/pub/bithacks.pdf> */
   static const char de_Bruijn_lookup[32] = {
     0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
     31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
diff --git a/lib/dup2.c b/lib/dup2.c
index b89f837..85c1a44 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -88,7 +88,7 @@ ms_windows_dup2 (int fd, int desired_fd)
     }
 
   /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
-     http://bugs.winehq.org/show_bug.cgi?id=21289 */
+     https://bugs.winehq.org/show_bug.cgi?id=21289 */
   if (desired_fd < 0)
     {
       errno = EBADF;
diff --git a/lib/filevercmp.c b/lib/filevercmp.c
index 56c9821..4026097 100644
--- a/lib/filevercmp.c
+++ b/lib/filevercmp.c
@@ -79,7 +79,7 @@ order (unsigned char c)
    specification can be found in the Debian Policy Manual in the
    section on the 'Version' control field.  This version of the code
    implements that from s5.6.12 of Debian Policy v3.8.0.1
-   http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version */
+   https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version 
*/
 static int _GL_ATTRIBUTE_PURE
 verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len)
 {
diff --git a/lib/fstatat.c b/lib/fstatat.c
index d09add0..67e48d9 100644
--- a/lib/fstatat.c
+++ b/lib/fstatat.c
@@ -111,7 +111,7 @@ stat_func (char const *name, struct stat *st)
 # endif
 
 /* Replacement for Solaris' function by the same name.
-   <http://www.google.com/search?q=fstatat+site:docs.sun.com>
+   <https://www.google.com/search?q=fstatat+site:docs.oracle.com>
    First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE").
    Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd.
    If either the save_cwd or the restore_cwd fails (relatively unlikely),
diff --git a/lib/fsync.c b/lib/fsync.c
index a52e664..c25f1db 100644
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -2,8 +2,8 @@
    cross-compilers like MinGW.
 
    This is derived from sqlite3 sources.
-   http://www.sqlite.org/cvstrac/rlog?f=sqlite/src/os_win.c
-   http://www.sqlite.org/copyright.html
+   https://www.sqlite.org/src/finfo?name=src/os_win.c
+   https://www.sqlite.org/copyright.html
 
    Written by Richard W.M. Jones <rjones.at.redhat.com>
 
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index 029e797..bcc79f0 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -108,7 +108,7 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, 
FLOAT x)
      Andrysco M, Jhala R, Lerner S. Printing floating-point numbers:
      a faster, always correct method. ACM SIGPLAN notices - POPL '16.
      2016;51(1):555-67 <http://dx.doi.org/10.1145/2914770.2837654>; draft at
-     <http://cseweb.ucsd.edu/~lerner/papers/fp-printing-popl16.pdf>.  */
+     <https://cseweb.ucsd.edu/~lerner/papers/fp-printing-popl16.pdf>.  */
 
   PROMOTED_FLOAT promoted_x = x;
   char format[sizeof "%-+ 0*.*Lg"];
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
index 3ee05a3..f73712c 100644
--- a/lib/ftoastr.h
+++ b/lib/ftoastr.h
@@ -96,7 +96,7 @@ enum
    DIG digits.  For why the "+ 1" is needed, see "Binary to Decimal
    Conversion" in David Goldberg's paper "What Every Computer
    Scientist Should Know About Floating-Point Arithmetic"
-   <http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html>.  */
+   <https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html>.  */
 # define _GL_FLOAT_PREC_BOUND(dig) \
    (INT_BITS_STRLEN_BOUND ((dig) * _GL_FLOAT_DIG_BITS_BOUND) + 1)
 
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 9500871..d8afec4 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -558,6 +558,7 @@ LIBGPM = @LIBGPM@
 LIBHESIOD = @LIBHESIOD@
 LIBINTL = @LIBINTL@
 LIBJPEG = @LIBJPEG@
+LIBLCMS2 = @LIBLCMS2@
 LIBMODULES = @LIBMODULES@
 LIBOBJS = @LIBOBJS@
 LIBOTF_CFLAGS = @LIBOTF_CFLAGS@
diff --git a/lib/intprops.h b/lib/intprops.h
index 400ba5b..a34e81c 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -26,7 +26,7 @@
 #define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
 
 /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
-   <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>.  */
+   <https://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>.  */
 #define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
 
 /* The extra casts in the following macros work around compiler bugs,
@@ -179,7 +179,7 @@
 /* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
    See above for restrictions.  Avoid && and || as they tickle
    bugs in Sun C 5.11 2010/08/13 and other compilers; see
-   <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>.  */
+   <https://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>.  */
 #define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max)     \
   ((b) < 0                                              \
    ? ((a) < 0                                           \
@@ -443,7 +443,7 @@
    implementation-defined result or signal for values outside T's
    range.  However, code that works around this theoretical problem
    runs afoul of a compiler bug in Oracle Studio 12.3 x86.  See:
-   http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
+   https://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
    As the compiler bug is real, don't try to work around the
    theoretical problem.  */
 
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 1d8ebfa..9c32b14 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -200,7 +200,7 @@ typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
 /* When also using extern inline, suppress the use of static inline in
    standard headers of problematic Apple configurations, as Libc at
    least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
-   <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
+   <https://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
    Perhaps Apple will fix this some day.  */
 #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
      && (defined __i386__ || defined __x86_64__))
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 0d606c1..8960333 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -32,7 +32,7 @@
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 
 # if defined __DragonFly__          /* DragonFly */
-  /* See 
<http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>.
  */
+  /* See 
<https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>.
  */
 #  define fp_ ((struct { struct __FILE_public pub; \
                          struct { unsigned char *_base; int _size; } _bf; \
                          void *cookie; \
@@ -49,7 +49,7 @@
                          fpos_t _offset; \
                          /* More fields, not relevant here.  */ \
                        } *) fp)
-  /* See 
<http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>.
  */
+  /* See 
<https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>.
  */
 #  define _p pub._p
 #  define _flags pub._flags
 #  define _r pub._r
@@ -60,7 +60,7 @@
 
 # if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined 
__OpenBSD__ || defined __minix || defined __ANDROID__ /* NetBSD >= 1.5ZA, 
OpenBSD, Minix 3, Android */
   /* See 
<http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
-     and 
<http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
 */
+     and 
<https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
 */
   struct __sfileext
     {
       struct  __sbuf _ub; /* ungetc buffer */
@@ -81,7 +81,7 @@
 #ifdef __TANDEM                     /* NonStop Kernel */
 # ifndef _IOERR
 /* These values were determined by the program 'stdioext-flags' at
-   <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>.  */
+   <https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>.  */
 #  define _IOERR   0x40
 #  define _IOREAD  0x80
 #  define _IOWRT    0x4
@@ -132,7 +132,7 @@ struct _gl_real_FILE
 # define fp_ ((struct _gl_real_FILE *) fp)
 
 /* These values were determined by a program similar to the one at
-   <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>.  */
+   <https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>.  */
 # define _IOREAD   0x1
 # define _IOWRT    0x2
 # define _IORW     0x4
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 5cf3131..066e08e 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -152,7 +152,7 @@
 /* When also using extern inline, suppress the use of static inline in
    standard headers of problematic Apple configurations, as Libc at
    least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
-   <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
+   <https://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
    Perhaps Apple will fix this some day.  */
 #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
      && defined __GNUC__ && defined __STDC__)
@@ -610,7 +610,7 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
                   (const void *ptr, size_t s, size_t n, FILE *stream));
 
 /* Work around bug 11959 when fortifying glibc 2.4 through 2.15
-   <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
+   <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
    which sometimes causes an unwanted diagnostic for fwrite calls.
    This affects only function declaration attributes under certain
    versions of gcc and clang, and is not needed for C++.  */
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 8a383b3..c1dd07f 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -379,7 +379,7 @@ _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
    Close NEWFD first if it is open.
    Return newfd if successful, otherwise -1 and errno set.
    See the Linux man page at
-   <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
+   <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
 # if @HAVE_DUP3@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define dup3 rpl_dup3
@@ -1149,7 +1149,7 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
    Store the read-end as fd[0] and the write-end as fd[1].
    Return 0 upon success, or -1 with errno set upon failure.
    See also the Linux man page at
-   <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
+   <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
 # if @HAVE_PIPE2@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define pipe2 rpl_pipe2
diff --git a/lib/utimens.c b/lib/utimens.c
index a5716ac..55545e8 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -196,7 +196,7 @@ fdutimens (int fd, char const *file, struct timespec const 
timespec[2])
   /* Some Linux-based NFS clients are buggy, and mishandle timestamps
      of files in NFS file systems in some cases.  We have no
      configure-time test for this, but please see
-     <http://bugs.gentoo.org/show_bug.cgi?id=132673> for references to
+     <https://bugs.gentoo.org/show_bug.cgi?id=132673> for references to
      some of the problems with Linux 2.6.16.  If this affects you,
      compile with -DHAVE_BUGGY_NFS_TIME_STAMPS; this is reported to
      help in some cases, albeit at a cost in performance.  But you
@@ -250,8 +250,8 @@ fdutimens (int fd, char const *file, struct timespec const 
timespec[2])
           result = utimensat (AT_FDCWD, file, ts, 0);
 #  ifdef __linux__
           /* Work around a kernel bug:
-             http://bugzilla.redhat.com/442352
-             http://bugzilla.redhat.com/449910
+             https://bugzilla.redhat.com/show_bug.cgi?id=442352
+             https://bugzilla.redhat.com/show_bug.cgi?id=449910
              It appears that utimensat can mistakenly return 280 rather
              than -1 upon ENOSYS failure.
              FIXME: remove in 2010 or whenever the offending kernels
@@ -566,8 +566,8 @@ lutimens (char const *file, struct timespec const 
timespec[2])
       result = utimensat (AT_FDCWD, file, ts, AT_SYMLINK_NOFOLLOW);
 # ifdef __linux__
       /* Work around a kernel bug:
-         http://bugzilla.redhat.com/442352
-         http://bugzilla.redhat.com/449910
+         https://bugzilla.redhat.com/show_bug.cgi?id=442352
+         https://bugzilla.redhat.com/show_bug.cgi?id=449910
          It appears that utimensat can mistakenly return 280 rather
          than -1 upon ENOSYS failure.
          FIXME: remove in 2010 or whenever the offending kernels
diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el
index 72db03e..1d29560 100644
--- a/lisp/calendar/cal-tex.el
+++ b/lisp/calendar/cal-tex.el
@@ -266,7 +266,7 @@ specified in ARGS.  When ARGS is omitted, by default the 
option
 \"12pt,a4paper\" is passed. When ARGS has any other value, then
 no option is passed to the class.
 
-Insert the \"\\usepacakge{geometry}\" directive when ARGS
+Insert the \"\\usepackage{geometry}\" directive when ARGS
 contains the \"landscape\" string."
   (set-buffer (generate-new-buffer cal-tex-buffer))
   (save-match-data
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 6d9a7d9..71d46c1 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -286,27 +286,60 @@ BUFFER defaults to current buffer.  Does not modify 
BUFFER."
 
 
 (defmacro ert-with-message-capture (var &rest body)
-  "Execute BODY while collecting anything written with `message' in VAR.
+  "Execute BODY while collecting messages in VAR.
 
-Capture all messages produced by `message' when it is called from
-Lisp, and concatenate them separated by newlines into one string.
+Capture messages issued by Lisp code and concatenate them
+separated by newlines into one string.  This includes messages
+written by `message' as well as objects printed by `print',
+`prin1' and `princ' to the echo area.  Messages issued from C
+code using the above mentioned functions will not be captured.
 
 This is useful for separating the issuance of messages by the
 code under test from the behavior of the *Messages* buffer."
   (declare (debug (symbolp body))
            (indent 1))
-  (let ((g-advice (gensym)))
+  (let ((g-message-advice (gensym))
+        (g-print-advice (gensym))
+        (g-collector (gensym)))
     `(let* ((,var "")
-            (,g-advice (lambda (func &rest args)
-                         (if (or (null args) (equal (car args) ""))
-                             (apply func args)
-                           (let ((msg (apply #'format-message args)))
-                             (setq ,var (concat ,var msg "\n"))
-                             (funcall func "%s" msg))))))
-       (advice-add 'message :around ,g-advice)
+            (,g-collector (lambda (msg) (setq ,var (concat ,var msg))))
+            (,g-message-advice (ert--make-message-advice ,g-collector))
+            (,g-print-advice (ert--make-print-advice ,g-collector)))
+       (advice-add 'message :around ,g-message-advice)
+       (advice-add 'prin1 :around ,g-print-advice)
+       (advice-add 'princ :around ,g-print-advice)
+       (advice-add 'print :around ,g-print-advice)
        (unwind-protect
            (progn ,@body)
-         (advice-remove 'message ,g-advice)))))
+         (advice-remove 'print ,g-print-advice)
+         (advice-remove 'princ ,g-print-advice)
+         (advice-remove 'prin1 ,g-print-advice)
+         (advice-remove 'message ,g-message-advice)))))
+
+(defun ert--make-message-advice (collector)
+  "Create around advice for `message' for `ert-collect-messages'.
+COLLECTOR will be called with the message before it is passed
+to the real `message'."
+  (lambda (func &rest args)
+    (if (or (null args) (equal (car args) ""))
+        (apply func args)
+      (let ((msg (apply #'format-message args)))
+        (funcall collector (concat msg "\n"))
+        (funcall func "%s" msg)))))
+
+(defun ert--make-print-advice (collector)
+  "Create around advice for print functions for `ert-collect-messages'.
+The created advice function will just call the original function
+unless the output is going to the echo area (when PRINTCHARFUN is
+t or PRINTCHARFUN is nil and `standard-output' is t).  If the
+output is destined for the echo area, the advice function will
+convert it to a string and pass it to COLLECTOR first."
+  (lambda (func object &optional printcharfun)
+    (if (not (eq t (or printcharfun standard-output)))
+        (funcall func object printcharfun)
+      (funcall collector (with-output-to-string
+                           (funcall func object)))
+      (funcall func object printcharfun))))
 
 
 (provide 'ert-x)
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 077ad22..edba655 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -128,7 +128,7 @@ binding value is nil.  If all are non-nil, the value of 
THEN is
 returned, or the last form in ELSE is returned.
 
 Each element of VARLIST is a list (SYMBOL VALUEFORM) which binds
-SYMBOL to the value of VALUEFORM).  An element can additionally
+SYMBOL to the value of VALUEFORM.  An element can additionally
 be of the form (VALUEFORM), which is evaluated and checked for
 nil; i.e. SYMBOL can be omitted if only the test result is of
 interest."
diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el
index 44a315f..69c6741 100644
--- a/lisp/emacs-lisp/timer-list.el
+++ b/lisp/emacs-lisp/timer-list.el
@@ -25,7 +25,7 @@
 ;;; Code:
 
 ;;;###autoload
-(defun timer-list (&optional _ignore-auto _nonconfirm)
+(defun list-timers (&optional _ignore-auto _nonconfirm)
   "List all timers in a buffer."
   (interactive)
   (pop-to-buffer-same-window (get-buffer-create "*timer-list*"))
@@ -67,7 +67,7 @@
   (goto-char (point-min)))
 ;; This command can be destructive if they don't know what they are
 ;; doing.  Kids, don't try this at home!
-;;;###autoload (put 'timer-list 'disabled "Beware: manually canceling timers 
can ruin your Emacs session.")
+;;;###autoload (put 'list-timers 'disabled "Beware: manually canceling timers 
can ruin your Emacs session.")
 
 (defvar timer-list-mode-map
   (let ((map (make-sparse-keymap)))
@@ -84,7 +84,7 @@
   (setq bidi-paragraph-direction 'left-to-right)
   (setq truncate-lines t)
   (buffer-disable-undo)
-  (setq-local revert-buffer-function 'timer-list)
+  (setq-local revert-buffer-function #'list-timers)
   (setq buffer-read-only t)
   (setq header-line-format
         (format "%4s %10s %8s %s"
diff --git a/lisp/files.el b/lisp/files.el
index fe7cb1a..336bbc8 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -150,8 +150,13 @@ Called with an absolute file name as argument, it returns 
t to enable backup.")
 (defcustom buffer-offer-save nil
   "Non-nil in a buffer means always offer to save buffer on exit.
 Do so even if the buffer is not visiting a file.
-Automatically local in all buffers."
-  :type 'boolean
+Automatically local in all buffers.
+
+Set to the symbol `always' to offer to save buffer whenever
+`save-some-buffers' is called."
+  :type '(choice (const :tag "Never" nil)
+                 (const :tag "On Emacs exit" t)
+                 (const :tag "Whenever save-some-buffers is called" always))
   :group 'backup)
 (make-variable-buffer-local 'buffer-offer-save)
 (put 'buffer-offer-save 'permanent-local t)
@@ -5190,12 +5195,9 @@ change the additional actions you can take on files."
                     (not (buffer-base-buffer buffer))
                     (or
                      (buffer-file-name buffer)
-                     (and pred
-                          (progn
-                            (set-buffer buffer)
-                            (and buffer-offer-save (> (buffer-size) 0))))
-                     (buffer-local-value
-                      'write-contents-functions buffer))
+                     (with-current-buffer buffer
+                       (or (eq buffer-offer-save 'always)
+                           (and pred buffer-offer-save (> (buffer-size) 0)))))
                     (or (not (functionp pred))
                         (with-current-buffer buffer (funcall pred)))
                     (if arg
@@ -5336,7 +5338,7 @@ instance of such commands."
   "Make directory DIR if it is not already a directory.  Return nil."
   (condition-case err
       (make-directory-internal dir)
-    (file-already-exists
+    (error
      (unless (file-directory-p dir)
        (signal (car err) (cdr err))))))
 
@@ -5372,7 +5374,7 @@ raised."
          (while (progn
                   (setq parent (directory-file-name
                                 (file-name-directory dir)))
-                  (condition-case err
+                  (condition-case ()
                       (files--ensure-directory dir)
                     (file-missing
                      ;; Do not loop if root does not exist (Bug#2309).
@@ -5544,16 +5546,14 @@ into NEWNAME instead."
             ;; If NEWNAME is not a directory name, create it;
             ;; that is where we will copy the files of DIRECTORY.
             (make-directory newname parents))
-           ;; If NEWNAME is a directory name and COPY-CONTENTS
-           ;; is nil, copy into NEWNAME/[DIRECTORY-BASENAME].
-           ((not copy-contents)
-            (setq newname (concat newname
-                           (file-name-nondirectory directory)))
-            (and (file-exists-p newname)
-                 (not (file-directory-p newname))
-                 (error "Cannot overwrite non-directory %s with a directory"
-                        newname))
-            (make-directory newname t)))
+           ;; NEWNAME is a directory name.  If COPY-CONTENTS is non-nil,
+           ;; create NEWNAME if it is not already a directory;
+           ;; otherwise, create NEWNAME/[DIRECTORY-BASENAME].
+           ((if copy-contents
+                (or parents (not (file-directory-p newname)))
+              (setq newname (concat newname
+                                    (file-name-nondirectory directory))))
+            (make-directory (directory-file-name newname) parents)))
 
       ;; Copy recursively.
       (dolist (file
@@ -5565,7 +5565,7 @@ into NEWNAME instead."
              (filetype (car (file-attributes file))))
          (cond
           ((eq filetype t)       ; Directory but not a symlink.
-           (copy-directory file newname keep-time parents))
+           (copy-directory file target keep-time parents t))
           ((stringp filetype)    ; Symbolic link
            (make-symbolic-link filetype target t))
           ((copy-file file target t keep-time)))))
diff --git a/lisp/frame.el b/lisp/frame.el
index 5f0e97d..76c1842 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -604,11 +604,12 @@ new frame."
     (select-frame (make-frame))))
 
 (defvar before-make-frame-hook nil
-  "Functions to run before a frame is created.")
+  "Functions to run before `make-frame' creates a new frame.")
 
 (defvar after-make-frame-functions nil
-  "Functions to run after a frame is created.
-The functions are run with one arg, the newly created frame.")
+  "Functions to run after `make-frame' created a new frame.
+The functions are run with one argument, the newly created
+frame.")
 
 (defvar after-setting-font-hook nil
   "Functions to run after a frame's font has been changed.")
@@ -617,7 +618,7 @@ The functions are run with one arg, the newly created 
frame.")
 (define-obsolete-function-alias 'new-frame 'make-frame "22.1")
 
 (defvar frame-inherited-parameters '()
-  "Parameters `make-frame' copies from the `selected-frame' to the new frame.")
+  "Parameters `make-frame' copies from the selected to the new frame.")
 
 (defvar x-display-name)
 
@@ -632,9 +633,6 @@ form (NAME . VALUE), for example:
  (width . NUMBER)      The frame should be NUMBER characters in width.
  (height . NUMBER)     The frame should be NUMBER text lines high.
 
-You cannot specify either `width' or `height', you must specify
-neither or both.
-
  (minibuffer . t)      The frame should have a minibuffer.
  (minibuffer . nil)    The frame should have no minibuffer.
  (minibuffer . only)   The frame should contain only a minibuffer.
@@ -650,10 +648,10 @@ neither or both.
 In addition, any parameter specified in `default-frame-alist',
 but not present in PARAMETERS, is applied.
 
-Before creating the frame (via `frame-creation-function-alist'),
-this function runs the hook `before-make-frame-hook'.  After
-creating the frame, it runs the hook `after-make-frame-functions'
-with one arg, the newly created frame.
+Before creating the frame (via `frame-creation-function'), this
+function runs the hook `before-make-frame-hook'.  After creating
+the frame, it runs the hook `after-make-frame-functions' with one
+argument, the newly created frame.
 
 If a display parameter is supplied and a window-system is not,
 guess the window-system from the display.
diff --git a/lisp/frameset.el b/lisp/frameset.el
index 661f0ae..593451a 100644
--- a/lisp/frameset.el
+++ b/lisp/frameset.el
@@ -447,7 +447,7 @@ DO NOT MODIFY.  See `frameset-filter-alist' for a full 
description.")
      (buffer-predicate   . :never)
      (buried-buffer-list . :never)
      (delete-before      . :never)
-     (font               . frameset-filter-shelve-param)
+     (font               . frameset-filter-font-param)
      (foreground-color   . frameset-filter-sanitize-color)
      (fullscreen         . frameset-filter-shelve-param)
      (GUI:font           . frameset-filter-unshelve-param)
@@ -631,6 +631,17 @@ see `frameset-filter-alist'."
          (setcdr found val)
          nil))))
 
+(defun frameset-filter-font-param (current filtered parameters saving
+                                           &optional prefix)
+  "When switching from a tty frame to a GUI frame, remove the FONT param.
+
+When switching from a GUI frame to a tty frame, behave
+as `frameset-filter-shelve-param' does."
+  (or saving
+      (if (frameset-switch-to-gui-p parameters)
+          (frameset-filter-shelve-param current filtered parameters saving
+                                        prefix))))
+
 (defun frameset-filter-iconified (_current _filtered parameters saving)
   "Remove CURRENT when saving an iconified frame.
 This is used for positional parameters `left' and `top', which are
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 690dd28..a9e66ce 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -991,7 +991,6 @@ are replaced:
   %F   The first name if present, e.g.: \"John\", else fall
        back to the mail address.
   %L   The last name if present, e.g.: \"Doe\".
-  %Z, %z   The time zone in the numeric form, e.g.:\"+0000\".
 
 All other format specifiers are passed to `format-time-string'
 which is called using the date from the article your replying to, but
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 3f448f0..169d263 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1916,6 +1916,34 @@ CLICK position, kill the secondary selection."
         (> (length str) 0)
         (gui-set-selection 'SECONDARY str))))
 
+(defun secondary-selection-exist-p ()
+  "Return non-nil if the secondary selection exists in the current buffer."
+  (memq mouse-secondary-overlay (overlays-in (point-min) (point-max))))
+
+(defun secondary-selection-to-region ()
+  "Set beginning and end of the region to those of the secondary selection.
+This puts mark and point at the beginning and the end of the
+secondary selection, respectively.  This works when the secondary
+selection exists and the region does not exist in current buffer;
+the secondary selection will be deleted afterward.
+If the region is active, or the secondary selection doesn't exist,
+this function does nothing."
+  (when (and (not (region-active-p))
+             (secondary-selection-exist-p))
+    (let ((beg (overlay-start mouse-secondary-overlay))
+          (end (overlay-end mouse-secondary-overlay)))
+      (push-mark beg t t)
+      (goto-char end))
+    ;; Delete the secondary selection on current buffer.
+    (delete-overlay mouse-secondary-overlay)))
+
+(defun secondary-selection-from-region ()
+  "Set beginning and end of the secondary selection to those of the region.
+When there is no region, this function does nothing."
+  (when (region-active-p) ; Create the secondary selection from the region.
+    (delete-overlay mouse-secondary-overlay) ; Delete the secondary selection 
even on a different buffer.
+    (move-overlay mouse-secondary-overlay (region-beginning) (region-end))))
+
 
 (defcustom mouse-buffer-menu-maxlen 20
   "Number of buffers in one pane (submenu) of the buffer menu.
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 2956ba5..0c0dcb3b 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -232,6 +232,7 @@ non-Windows systems."
       ;; When the double-mouse-N comes in, a mouse-N has been executed already,
       ;; So by adding things up we get a squaring up (1, 3, 6, 10, 15, ...).
       (setq amt (* amt (event-click-count event))))
+    (when (numberp amt) (setq amt (* amt (event-line-count event))))
     (unwind-protect
        (let ((button (mwheel-event-button event)))
          (cond ((eq button mouse-wheel-down-event)
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index ed35c22..8658746 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -165,9 +165,13 @@ is consulted."
       (type   . "application/zip")
       ("copiousoutput"))
      ("pdf"
+      (viewer . pdf-view-mode)
+      (type . "application/pdf")
+      (test . window-system))
+     ("pdf"
       (viewer . doc-view-mode)
       (type . "application/pdf")
-      (test . (eq window-system 'x)))
+      (test . window-system))
      ("pdf"
       (viewer . "gv -safer %s")
       (type . "application/pdf")
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index c22869d..760d020 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -740,7 +740,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
 
                ;; Remote newname.
                (when (and (file-directory-p newname)
-                          (directory-name-p newname))
+                          (tramp-compat-directory-name-p newname))
                  (setq newname
                        (expand-file-name
                         (file-name-nondirectory filename) newname)))
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 5d9a1fd..214ad04 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -23,8 +23,9 @@
 
 ;;; Commentary:
 
-;; Tramp's main Emacs version for development is Emacs 26.  This
-;; package provides compatibility functions for Emacs 24 and Emacs 25.
+;; Tramp's main Emacs version for development is Emacs 27.  This
+;; package provides compatibility functions for Emacs 24, Emacs 25 and
+;; Emacs 26.
 
 ;;; Code:
 
@@ -104,6 +105,10 @@ Add the extension of F, if existing."
    'tramp-error vec-or-proc
    (if (fboundp 'user-error) 'user-error 'error) format args))
 
+;; `default-toplevel-value' has been declared in Emacs 24.4.
+(unless (fboundp 'default-toplevel-value)
+  (defalias 'default-toplevel-value 'symbol-value))
+
 ;; `file-attribute-*' are introduced in Emacs 25.1.
 
 (if (fboundp 'file-attribute-type)
@@ -163,14 +168,23 @@ This is a floating point number if the size is too large 
for an integer."
 This is a string of ten letters or dashes as in ls -l."
     (nth 8 attributes)))
 
-;; `default-toplevel-value' has been declared in Emacs 24.4.
-(unless (fboundp 'default-toplevel-value)
-  (defalias 'default-toplevel-value 'symbol-value))
-
 ;; `format-message' is new in Emacs 25.1.
 (unless (fboundp 'format-message)
   (defalias 'format-message 'format))
 
+;; `directory-name-p' is new in Emacs 25.1.
+(if (fboundp 'directory-name-p)
+    (defalias 'tramp-compat-directory-name-p 'directory-name-p)
+  (defsubst tramp-compat-directory-name-p (name)
+    "Return non-nil if NAME ends with a directory separator character."
+    (let ((len (length name))
+          (lastc ?.))
+      (if (> len 0)
+          (setq lastc (aref name (1- len))))
+      (or (= lastc ?/)
+          (and (memq system-type '(windows-nt ms-dos))
+               (= lastc ?\\))))))
+
 ;; `file-missing' is introduced in Emacs 26.1.
 (defconst tramp-file-missing
   (if (get 'file-missing 'error-conditions) 'file-missing 'file-error)
@@ -221,13 +235,6 @@ If NAME is a remote file name, the local part of NAME is 
unquoted."
        ((eq tramp-syntax 'sep) 'separate)
        (t tramp-syntax)))
 
-;; Older Emacsen keep incompatible autoloaded values of `tramp-syntax'.
-(eval-after-load 'tramp
-  '(unless
-       (memq tramp-syntax (tramp-compat-funcall (quote tramp-syntax-values)))
-     (tramp-compat-funcall
-      (quote tramp-change-syntax) (tramp-compat-tramp-syntax))))
-
 (provide 'tramp-compat)
 
 ;;; TODO:
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 7df5aa3..a744a53 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -613,7 +613,7 @@ use Cwd \"realpath\";
 
 sub myrealpath {
     my ($file) = @_;
-    return realpath($file) if -e $file;
+    return realpath($file) if (-e $file || -l $file);
 }
 
 sub recursive {
@@ -1139,12 +1139,7 @@ component is used as the target of the symlink."
                     (tramp-shell-quote-argument localname)))
            (with-current-buffer (tramp-get-connection-buffer v)
              (goto-char (point-min))
-             (setq result (buffer-substring (point-min) (point-at-eol))))
-           (when (and (file-symlink-p filename)
-                      (string-equal result localname))
-             (tramp-error
-              v 'file-error
-              "Apparent cycle of symbolic links for %s" filename)))
+             (setq result (buffer-substring (point-min) (point-at-eol)))))
 
           ;; Use Perl implementation.
           ((and (tramp-get-remote-perl v)
@@ -1198,16 +1193,6 @@ component is used as the target of the symlink."
                         (setq numchase (1+ numchase))
                         (when (file-name-absolute-p symlink-target)
                           (setq result nil))
-                        ;; If the symlink was absolute, we'll get a
-                        ;; string like "/address@hidden:/some/target";
-                        ;; extract the "/some/target" part from it.
-                        (when (tramp-tramp-file-p symlink-target)
-                          (unless (tramp-equal-remote filename symlink-target)
-                            (tramp-error
-                             v 'file-error
-                             "Symlink target `%s' on wrong host"
-                             symlink-target))
-                          (setq symlink-target localname))
                         (setq steps
                               (append
                                (split-string symlink-target "/" 'omit) steps)))
@@ -1226,6 +1211,13 @@ component is used as the target of the symlink."
                        "/"))
                (when (string= "" result)
                  (setq result "/")))))
+
+         ;; Detect cycle.
+         (when (and (file-symlink-p filename)
+                    (string-equal result localname))
+           (tramp-error
+            v 'file-error
+            "Apparent cycle of symbolic links for %s" filename))
          ;; If the resulting localname looks remote, we must quote it
          ;; for security reasons.
          (when (or quoted (file-remote-p result))
@@ -1985,7 +1977,7 @@ tramp-sh-handle-file-name-all-completions: internal error 
accessing `%s': `%s'"
          ;; scp or rsync DTRT.
          (progn
            (when (and (file-directory-p newname)
-                      (not (directory-name-p newname)))
+                      (not (tramp-compat-directory-name-p newname)))
              (tramp-error v 'file-already-exists newname))
            (setq dirname (directory-file-name (expand-file-name dirname))
                  newname (directory-file-name (expand-file-name newname)))
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 4969566..35aa811 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -415,7 +415,7 @@ pass to the OPERATION."
        (with-tramp-progress-reporter
            v 0 (format "Copying %s to %s" dirname newname)
          (when (and (file-directory-p newname)
-                    (not (directory-name-p newname)))
+                    (not (tramp-compat-directory-name-p newname)))
            (tramp-error v 'file-already-exists newname))
          (cond
           ;; We must use a local temporary directory.
@@ -535,7 +535,7 @@ pass to the OPERATION."
                ;; Reset the transfer process properties.
                (tramp-set-connection-property v "process-name" nil)
                (tramp-set-connection-property v "process-buffer" nil)
-               (when t1 (delete-directory tmpdir 'recurse))))
+               (when t1 (delete-directory tmpdir 'recursive))))
 
            ;; Handle KEEP-DATE argument.
            (when keep-date
@@ -586,7 +586,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
 
          ;; Remote newname.
          (when (and (file-directory-p newname)
-                    (directory-name-p newname))
+                    (tramp-compat-directory-name-p newname))
            (setq newname
                  (expand-file-name (file-name-nondirectory filename) newname)))
 
@@ -1583,6 +1583,10 @@ If VEC has no cifs capabilities, exchange \"/\" by 
\"\\\\\"."
   "Read entries which match DIRECTORY.
 Either the shares are listed, or the `dir' command is executed.
 Result is a list of (LOCALNAME MODE SIZE MONTH DAY TIME YEAR)."
+  ;; If CIFS capabilities are enabled, symlinks are not listed
+  ;; by `dir'.  This is a consequence of
+  ;; <https://www.samba.org/samba/news/symlink_attack.html>.  See also
+  ;; <https://bugzilla.samba.org/show_bug.cgi?id=5116>.
   (with-parsed-tramp-file-name (file-name-as-directory directory) nil
     (setq localname (or localname "/"))
     (with-tramp-file-property v localname "file-entries"
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 4577607..3573eeb 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3169,7 +3169,7 @@ User is always nil."
 
 (defun tramp-handle-file-truename (filename)
   "Like `file-truename' for Tramp files."
-  (let ((result filename)
+  (let ((result (expand-file-name filename))
        (numchase 0)
        ;; Don't make the following value larger than
        ;; necessary.  People expect an error message in a
@@ -3180,7 +3180,7 @@ User is always nil."
        symlink-target)
     (format
      "%s%s"
-     (with-parsed-tramp-file-name (expand-file-name result) v1
+     (with-parsed-tramp-file-name result v1
        (with-tramp-file-property v1 v1-localname "file-truename"
         (while (and (setq symlink-target (file-symlink-p result))
                     (< numchase numchase-limit))
@@ -3850,7 +3850,7 @@ Erase echoed commands if exists."
                     (min (+ (point-min) tramp-echo-mark-marker-length)
                          (point-max))))))
       ;; No echo to be handled, now we can look for the regexp.
-      ;; Sometimes, lines are much to long, and we run into a "Stack
+      ;; Sometimes, lines are much too long, and we run into a "Stack
       ;; overflow in regexp matcher".  For example, //DIRED// lines of
       ;; directory listings with some thousand files.  Therefore, we
       ;; look from the end.
@@ -4547,16 +4547,23 @@ Only works for Bourne-like shells."
               (t                  process)))
        pid)
     ;; If it's a Tramp process, send the INT signal remotely.
-    (when (and (processp proc) (process-live-p proc)
-              (setq pid (process-get proc 'remote-pid)))
-      (tramp-message proc 5 "Interrupt process %s with pid %s" proc pid)
-      ;; This is for tramp-sh.el.  Other backends do not support this (yet).
-      (tramp-compat-funcall
-       'tramp-send-command
-       (tramp-get-connection-property proc "vector" nil)
-       (format "kill -2 %d" pid))
-      ;; Report success.
-      proc)))
+    (when (and (processp proc) (setq pid (process-get proc 'remote-pid)))
+      (if (not  (process-live-p proc))
+         (tramp-error proc 'error "Process %s is not active" proc)
+       (tramp-message proc 5 "Interrupt process %s with pid %s" proc pid)
+       ;; This is for tramp-sh.el.  Other backends do not support this (yet).
+       (tramp-compat-funcall
+        'tramp-send-command
+        (tramp-get-connection-property proc "vector" nil)
+        (format "kill -2 %d" pid))
+       ;; Wait, until the process has disappeared.
+       (with-timeout
+           (1 (tramp-error proc 'error "Process %s did not interrupt" proc))
+         (while (process-live-p proc)
+           ;; We cannot run `tramp-accept-process-output', it blocks timers.
+           (accept-process-output proc 0.1)))
+       ;; Report success.
+       proc))))
 
 ;; `interrupt-process-functions' exists since Emacs 26.1.
 (when (boundp 'interrupt-process-functions)
diff --git a/lisp/org/ChangeLog.1 b/lisp/org/ChangeLog.1
index 366a3ee..ee50f6f 100644
--- a/lisp/org/ChangeLog.1
+++ b/lisp/org/ChangeLog.1
@@ -5015,10 +5015,10 @@
        * ox-latex.el (org-latex-listings): Update docstring.
 
        * org-pcomplete.el (pcomplete/org-mode/file-option/options):
-       Apply changes to export back-end definiton.
+       Apply changes to export back-end definition.
 
        * org.el (org-get-export-keywords): Apply changes to export
-       back-end definiton.
+       back-end definition.
 
        * ox-html.el (org-html--format-toc-headline): Make use of
        anonymous back-ends.
diff --git a/lisp/progmodes/bat-mode.el b/lisp/progmodes/bat-mode.el
index f4852fe..102c318 100644
--- a/lisp/progmodes/bat-mode.el
+++ b/lisp/progmodes/bat-mode.el
@@ -84,11 +84,11 @@
          . 'bat-label-face)
         ("\\_<\\(defined\\|set\\)\\_>[ \t]*\\(\\(\\sw\\|\\s_\\)+\\)"
          (2 font-lock-variable-name-face))
-        ("%\\(\\(\\sw\\|\\s_\\)+\\)%"
+        ("%\\([^%~ \n]+\\)%?"
          (1 font-lock-variable-name-face))
-        ("!\\(\\(\\sw\\|\\s_\\)+\\)!"  ; delayed-expansion !variable!
+        ("!\\([^!%~ \n]+\\)!?"  ; delayed-expansion !variable!
          (1 font-lock-variable-name-face))
-        
("%%\\(?:~[adfnpstxz]*\\(?:\\$\\(\\(?:\\sw\\|\\s_\\)+\\):\\)?\\)?\\([]!#$&-:?-[_-{}~]\\)"
+        
("%%\\(?:~[adfnpstxz]*\\(?:\\$\\(\\(?:\\sw\\|\\s_\\|_\\)+\\):\\)?\\)?\\([]!#$&-:?-[_-{}~]\\)"
          (1 font-lock-variable-name-face nil t) ; PATH expansion
          (2 font-lock-variable-name-face)) ; iteration variable or positional 
parameter
         ("[ =][-/]+\\(\\w+\\)"
diff --git a/lisp/simple.el b/lisp/simple.el
index 1ffe181..4e42fd5 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -434,10 +434,6 @@ A non-nil INTERACTIVE argument means to run the 
`post-self-insert-hook'."
           ;; Do the rest in post-self-insert-hook, because we want to do it
           ;; *before* other functions on that hook.
           (lambda ()
-            ;; We are not going to insert any newlines if arg is
-            ;; non-positive.
-            (or (and (numberp arg) (<= arg 0))
-                (cl-assert (eq ?\n (char-before))))
             ;; Mark the newline(s) `hard'.
             (if use-hard-newlines
                 (set-hard-newline-properties
@@ -456,25 +452,22 @@ A non-nil INTERACTIVE argument means to run the 
`post-self-insert-hook'."
             ;; starts a page.
             (or was-page-start
                 (move-to-left-margin nil t)))))
-    (unwind-protect
-        (if (not interactive)
-            ;; FIXME: For non-interactive uses, many calls actually
-            ;; just want (insert "\n"), so maybe we should do just
-            ;; that, so as to avoid the risk of filling or running
-            ;; abbrevs unexpectedly.
-            (let ((post-self-insert-hook (list postproc)))
-              (self-insert-command arg))
-          (unwind-protect
-              (progn
-                (add-hook 'post-self-insert-hook postproc nil t)
-                (self-insert-command arg))
-            ;; We first used let-binding to protect the hook, but that
-            ;; was naive since add-hook affects the symbol-default
-            ;; value of the variable, whereas the let-binding might
-            ;; only protect the buffer-local value.
-            (remove-hook 'post-self-insert-hook postproc t)))
-      (cl-assert (not (member postproc post-self-insert-hook)))
-      (cl-assert (not (member postproc (default-value 
'post-self-insert-hook))))))
+    (if (not interactive)
+       ;; FIXME: For non-interactive uses, many calls actually
+       ;; just want (insert "\n"), so maybe we should do just
+       ;; that, so as to avoid the risk of filling or running
+       ;; abbrevs unexpectedly.
+       (let ((post-self-insert-hook (list postproc)))
+         (self-insert-command arg))
+      (unwind-protect
+         (progn
+           (add-hook 'post-self-insert-hook postproc nil t)
+           (self-insert-command arg))
+       ;; We first used let-binding to protect the hook, but that
+       ;; was naive since add-hook affects the symbol-default
+       ;; value of the variable, whereas the let-binding might
+       ;; only protect the buffer-local value.
+       (remove-hook 'post-self-insert-hook postproc t))))
   nil)
 
 (defun set-hard-newline-properties (from to)
diff --git a/lisp/subr.el b/lisp/subr.el
index 79ae1f4..cf15ec2 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -289,7 +289,7 @@ The name is made by appending `gensym-counter' to PREFIX.
 PREFIX is a string, and defaults to \"g\"."
   (let ((num (prog1 gensym-counter
                (setq gensym-counter (1+ gensym-counter)))))
-    (make-symbol (format "%s%d" prefix num))))
+    (make-symbol (format "%s%d" (or prefix "g") num))))
 
 (defun ignore (&rest _ignore)
   "Do nothing and return nil.
@@ -1270,6 +1270,11 @@ See `event-start' for a description of the value 
returned."
   "Return the multi-click count of EVENT, a click or drag event.
 The return value is a positive integer."
   (if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1))
+
+(defsubst event-line-count (event)
+  "Return the line count of EVENT, a mousewheel event.
+The return value is a positive integer."
+  (if (and (consp event) (integerp (nth 3 event))) (nth 3 event) 1))
 
 ;;;; Extracting fields of the positions in an event.
 
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 68b659b..bc211ea 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -736,6 +736,25 @@ See the documentation of 
`create-fontset-from-fontset-spec' for the format.")
 (global-unset-key [horizontal-scroll-bar drag-mouse-1])
 
 
+;;;; macOS-like defaults for trackpad and mouse wheel scrolling on
+;;;; macOS 10.7+.
+
+;; FIXME: This doesn't look right.  Is there a better way to do this
+;; that keeps customize happy?
+(let ((appkit-version (progn
+                        (string-match "^appkit-\\([^\s-]*\\)" 
ns-version-string)
+                        (string-to-number (match-string 1 
ns-version-string)))))
+  ;; Appkit 1138 ~= macOS 10.7.
+  (when (and (featurep 'cocoa) (>= appkit-version 1138))
+    (setq mouse-wheel-scroll-amount '(1 ((shift) . 5) ((control))))
+    (put 'mouse-wheel-scroll-amount 'customized-value
+         (list (custom-quote (symbol-value 'mouse-wheel-scroll-amount))))
+
+    (setq mouse-wheel-progressive-speed nil)
+    (put 'mouse-wheel-progressive-speed 'customized-value
+         (list (custom-quote (symbol-value 'mouse-wheel-progressive-speed))))))
+
+
 ;;;; Color support.
 
 ;; Functions for color panel + drag
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 0c0a51e..6a16962 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1492,8 +1492,10 @@ This is passed to the Ispell process using the `-p' 
switch.")
                (assoc ispell-current-dictionary ispell-local-dictionary-alist)
                (assoc ispell-current-dictionary ispell-dictionary-alist)
                (error "No data for dictionary \"%s\" in 
`ispell-local-dictionary-alist' or `ispell-dictionary-alist'"
-                      ispell-current-dictionary))))
-    (decode-coding-string (nth n slot) (ispell-get-coding-system) t)))
+                      ispell-current-dictionary)))
+         (str (nth n slot)))
+    (if (stringp str)
+        (decode-coding-string str (ispell-get-coding-system) t))))
 
 (defun ispell-get-casechars ()
   (ispell-get-decoded-string 1))
diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
index 52f56ed..d6963d0 100644
--- a/lisp/vc/log-view.el
+++ b/lisp/vc/log-view.el
@@ -608,10 +608,16 @@ considered file(s)."
     (log-view-diff-common beg end t)))
 
 (defun log-view-diff-common (beg end &optional whole-changeset)
-  (let ((to (log-view-current-tag beg))
-        (fr (log-view-current-tag end)))
-    (when (string-equal fr to)
-      ;; TO and FR are the same, look at the previous revision.
+  (let* ((to (log-view-current-tag beg))
+         (fr-entry (log-view-current-entry end))
+         (fr (cadr fr-entry)))
+    ;; When TO and FR are the same, or when point is on a line after
+    ;; the last entry, look at the previous revision.
+    (when (or (string-equal fr to)
+              (>= (point)
+                  (save-excursion
+                    (goto-char (car fr-entry))
+                    (forward-line))))
       (setq fr (vc-call-backend log-view-vc-backend 'previous-revision nil 
fr)))
     (vc-diff-internal
      t (list log-view-vc-backend
diff --git a/lisp/xdg.el b/lisp/xdg.el
index e94fa8e..76106f4 100644
--- a/lisp/xdg.el
+++ b/lisp/xdg.el
@@ -84,7 +84,7 @@
 
 (defun xdg-thumb-uri (filename)
   "Return the canonical URI for FILENAME.
-If FILENAME has absolute path /foo/bar.jpg, its canonical URI is
+If FILENAME has absolute file name /foo/bar.jpg, its canonical URI is
 file:///foo/bar.jpg"
   (concat "file://" (expand-file-name filename)))
 
@@ -197,8 +197,6 @@ Optional argument GROUP defaults to the string \"Desktop 
Entry\"."
     (unless (looking-at xdg-desktop-group-regexp)
       (error "Expected group name!  Instead saw: %s"
              (buffer-substring (point) (point-at-eol))))
-    (unless (equal (match-string 1) "Desktop Entry")
-      (error "Wrong first group: %s" (match-string 1)))
     (when group
       (while (and (re-search-forward xdg-desktop-group-regexp nil t)
                   (not (equal (match-string 1) group)))))
diff --git a/m4/alloca.m4 b/m4/alloca.m4
index 7f0604c..d122431 100644
--- a/m4/alloca.m4
+++ b/m4/alloca.m4
@@ -44,12 +44,12 @@ AC_DEFUN([gl_FUNC_ALLOCA],
 AC_DEFUN([gl_PREREQ_ALLOCA], [:])
 
 # This works around a bug in autoconf <= 2.68.
-# See <http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00277.html>.
+# See <https://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00277.html>.
 
 m4_version_prereq([2.69], [] ,[
 
 # This is taken from the following Autoconf patch:
-# 
http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
+# 
https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=6cd9f12520b0d6f76d3230d7565feba1ecf29497
 
 # _AC_LIBOBJ_ALLOCA
 # -----------------
diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4
index 00f9609..c08af18 100644
--- a/m4/extern-inline.m4
+++ b/m4/extern-inline.m4
@@ -11,7 +11,7 @@ AC_DEFUN([gl_EXTERN_INLINE],
 [/* Please see the Gnulib manual for how to use these macros.
 
    Suppress extern inline with HP-UX cc, as it appears to be broken; see
-   <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
+   <https://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
 
    Suppress extern inline with Sun C in standards-conformance mode, as it
    mishandles inline functions that call each other.  E.g., for 'inline void f
@@ -28,16 +28,16 @@ AC_DEFUN([gl_EXTERN_INLINE],
    from calling static functions.  This bug is known to occur on:
 
      OS X 10.8 and earlier; see:
-     http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html
+     https://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html
 
      DragonFly; see
      
http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log
 
      FreeBSD; see:
-     http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html
+     https://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html
 
    OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
-   for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
+   for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
    Assume DragonFly and FreeBSD will be similar.  */
 #if (((defined __APPLE__ && defined __MACH__) \
       || defined __DragonFly__ || defined __FreeBSD__) \
diff --git a/m4/fstatat.m4 b/m4/fstatat.m4
index 75cf011..b29ec92 100644
--- a/m4/fstatat.m4
+++ b/m4/fstatat.m4
@@ -20,7 +20,7 @@ AC_DEFUN([gl_FUNC_FSTATAT],
     HAVE_FSTATAT=0
   else
     dnl Test for an AIX 7.1 bug; see
-    dnl <http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>.
+    dnl <https://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>.
     AC_CACHE_CHECK([whether fstatat (..., 0) works],
       [gl_cv_func_fstatat_zero_flag],
       [AC_RUN_IFELSE(
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 36f2acc..36da841 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -228,13 +228,13 @@ m4_ifndef([AS_VAR_IF],
 # This is like AC_PROG_CC_C99, except that
 # - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60,
 # - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
-#   <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
+#   <https://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
 #   but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
-#   <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
+#   <https://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
 # Remaining problems:
 # - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
 #   to CC twice
-#   <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
+#   <https://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
 # - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
 AC_DEFUN([gl_PROG_CC_C99],
 [
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index eb89325..d10bcd0 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,4 +1,4 @@
-# manywarnings.m4 serial 12
+# manywarnings.m4 serial 13
 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -267,18 +267,23 @@ m4_defun([gl_MANYWARN_ALL_GCC(C)],
 
   # gcc --help=warnings outputs an unusual form for these options; list
   # them here so that the above 'comm' command doesn't report a false match.
-  # Would prefer "min (PTRDIFF_MAX, SIZE_MAX)", but it must be a literal
-  # and AC_COMPUTE_INT requires it to fit in a long:
+  # Would prefer "min (PTRDIFF_MAX, SIZE_MAX)", but it must be a literal.
+  # Also, AC_COMPUTE_INT requires it to fit in a long; it is 2**63 on
+  # the only platforms where it does not fit in a long, so make that
+  # a special case.
   AC_MSG_CHECKING([max safe object size])
   AC_COMPUTE_INT([gl_alloc_max],
-    [(LONG_MAX < PTRDIFF_MAX ? LONG_MAX : PTRDIFF_MAX) < (size_t) -1
-     ? (LONG_MAX < PTRDIFF_MAX ? LONG_MAX : PTRDIFF_MAX)
-     : (size_t) -1],
+    [LONG_MAX < (PTRDIFF_MAX < (size_t) -1 ? PTRDIFF_MAX : (size_t) -1)
+     ? -1
+     : PTRDIFF_MAX < (size_t) -1 ? (long) PTRDIFF_MAX : (long) (size_t) -1],
     [[#include <limits.h>
       #include <stddef.h>
       #include <stdint.h>
     ]],
     [gl_alloc_max=2147483647])
+  case $gl_alloc_max in
+    -1) gl_alloc_max=9223372036854775807;;
+  esac
   AC_MSG_RESULT([$gl_alloc_max])
   gl_manywarn_set="$gl_manywarn_set -Walloc-size-larger-than=$gl_alloc_max"
   gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
diff --git a/m4/std-gnu11.m4 b/m4/std-gnu11.m4
index bd34aa1..3c2f26f 100644
--- a/m4/std-gnu11.m4
+++ b/m4/std-gnu11.m4
@@ -369,7 +369,7 @@ dnl         just the module.  Instead, define the (private) 
symbol
 dnl            _STDC_C99, which suppresses a bogus failure in <stdbool.h>.
 dnl            The resulting compiler passes the test case here, and that's
 dnl            good enough.  For more, please see the thread starting at:
-dnl            http://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
+dnl            
https://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
 dnl Tru64      -c99
 dnl with extended modes being tried first.
 [[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x 
-qlanglvl=extc99]], [$1], [$2])[]dnl
@@ -458,7 +458,7 @@ dnl preferably extc11.
 # --------------
 # Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
 # as that'd be incompatible with how Automake redefines AC_PROG_CC.  See
-# <http://lists.gnu.org/archive/html/autoconf/2012-10/msg00048.html>.
+# <https://lists.gnu.org/archive/html/autoconf/2012-10/msg00048.html>.
 AU_DEFUN([AC_PROG_CC_C89],
   [AC_REQUIRE([AC_PROG_CC])],
   [$0 is obsolete; use AC_PROG_CC]
diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4
index 34224d7..06268cf 100644
--- a/m4/sys_types_h.m4
+++ b/m4/sys_types_h.m4
@@ -40,7 +40,7 @@ AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
 m4_version_prereq([2.70], [], [
 
 # This is taken from the following Autoconf patch:
-# https://git.sv.gnu.org/cgit/autoconf.git/commit/?id=e17a30e98
+# 
http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=e17a30e987d7ee695fb4294a82d987ec3dc9b974
 
 m4_undefine([AC_HEADER_MAJOR])
 AC_DEFUN([AC_HEADER_MAJOR],
diff --git a/m4/vararrays.m4 b/m4/vararrays.m4
index 8391121..38a3ed2 100644
--- a/m4/vararrays.m4
+++ b/m4/vararrays.m4
@@ -27,7 +27,7 @@ AC_DEFUN([AC_C_VARARRAYS],
             [[/* Test for VLA support.  This test is partly inspired
                  from examples in the C standard.  Use at least two VLA
                  functions to detect the GCC 3.4.3 bug described in:
-                 
http://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
+                 
https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
                  */
               #ifdef __STDC_NO_VLA__
                syntax error;
diff --git a/src/Makefile.in b/src/Makefile.in
index 0e55ad4..9a8c9c8 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -280,7 +280,7 @@ GNU_OBJC_CFLAGS=$(patsubst 
-specs=%-hardened-cc1,,@GNU_OBJC_CFLAGS@)
 ## w32xfns.o w32select.o image.o w32uniscribe.o if HAVE_W32, else
 ## empty.
 address@hidden@
-## -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32 lusp10 -lcomctl32
+## -lkernel32 -luser32 -lusp10 -lgdi32 -lole32 -lcomdlg32 -lcomctl32
 ## --lwinspool if HAVE_W32, else empty.
 address@hidden@
 
diff --git a/src/data.c b/src/data.c
index 95bf06e..e070be6 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3010,16 +3010,16 @@ static Lisp_Object
 minmax_driver (ptrdiff_t nargs, Lisp_Object *args,
               enum Arith_Comparison comparison)
 {
-  eassume (0 < nargs);
-  Lisp_Object accum = args[0]; /* pacify GCC */
-  for (ptrdiff_t argnum = 0; argnum < nargs; argnum++)
+  Lisp_Object accum = args[0];
+  CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (accum);
+  for (ptrdiff_t argnum = 1; argnum < nargs; argnum++)
     {
       Lisp_Object val = args[argnum];
       CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val);
-      if (argnum == 0 || !NILP (arithcompare (val, accum, comparison)))
+      if (!NILP (arithcompare (val, accum, comparison)))
        accum = val;
-      else if (FLOATP (accum) && isnan (XFLOAT_DATA (accum)))
-       return accum;
+      else if (FLOATP (val) && isnan (XFLOAT_DATA (val)))
+       return val;
     }
   return accum;
 }
diff --git a/src/editfns.c b/src/editfns.c
index b03eb94..2f8b075 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -187,7 +187,8 @@ tzlookup (Lisp_Object zone, bool settz)
                  if (sec != 0)
                    prec += 2, numzone = 100 * numzone + sec;
                }
-             sprintf (tzbuf, tzbuf_format, prec, numzone,
+             sprintf (tzbuf, tzbuf_format, prec,
+                      XINT (zone) < 0 ? -numzone : numzone,
                       &"-"[XINT (zone) < 0], hour, min, sec);
              zone_string = tzbuf;
            }
diff --git a/src/emacs.c b/src/emacs.c
index 1ad8af7..0fe7d91 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -252,7 +252,7 @@ Initialization options:\n\
     "\
 Action options:\n\
 \n\
-FILE                    visit FILE using find-file\n\
+FILE                    visit FILE\n\
 +LINE                   go to line LINE in next FILE\n\
 +LINE:COLUMN            go to line LINE, column COLUMN, in next FILE\n\
 --directory, -L DIR     prepend DIR to load-path (with :DIR, append DIR)\n\
@@ -260,13 +260,13 @@ FILE                    visit FILE using find-file\n\
 --execute EXPR          evaluate Emacs Lisp expression EXPR\n\
 ",
     "\
---file FILE             visit FILE using find-file\n\
---find-file FILE        visit FILE using find-file\n\
+--file FILE             visit FILE\n\
+--find-file FILE        visit FILE\n\
 --funcall, -f FUNC      call Emacs Lisp function FUNC with no arguments\n\
 --insert FILE           insert contents of FILE into current buffer\n\
 --kill                  exit without asking for confirmation\n\
 --load, -l FILE         load Emacs Lisp FILE using the load function\n\
---visit FILE            visit FILE using find-file\n\
+--visit FILE            visit FILE\n\
 \n\
 ",
     "\
diff --git a/src/eval.c b/src/eval.c
index 62e2196..39d7836 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1428,7 +1428,7 @@ push_handler (Lisp_Object tag_ch_val, enum handlertype 
handlertype)
 struct handler *
 push_handler_nosignal (Lisp_Object tag_ch_val, enum handlertype handlertype)
 {
-  struct handler *c = handlerlist->nextfree;
+  struct handler *CACHEABLE c = handlerlist->nextfree;
   if (!c)
     {
       c = malloc (sizeof *c);
diff --git a/src/keyboard.c b/src/keyboard.c
index 4db50be..e8701b8 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5925,7 +5925,10 @@ make_lispy_event (struct input_event *event)
                                      ASIZE (wheel_syms));
        }
 
-       if (event->modifiers & (double_modifier | triple_modifier))
+        if (NUMBERP (event->arg))
+          return list4 (head, position, make_number (double_click_count),
+                        event->arg);
+       else if (event->modifiers & (double_modifier | triple_modifier))
          return list3 (head, position, make_number (double_click_count));
        else
          return list2 (head, position);
diff --git a/src/lcms.c b/src/lcms.c
index f543a03..a5e5279 100644
--- a/src/lcms.c
+++ b/src/lcms.c
@@ -139,6 +139,26 @@ chroma, and hue, respectively. The parameters each default 
to 1.  */)
   return make_float (cmsCIE2000DeltaE (&Lab1, &Lab2, Kl, Kc, Kh));
 }
 
+static double
+deg2rad (double degrees)
+{
+  return M_PI * degrees / 180.0;
+}
+
+static cmsCIEXYZ illuminant_d65 = { .X = 95.0455, .Y = 100.0, .Z = 108.8753 };
+
+static void
+default_viewing_conditions (const cmsCIEXYZ *wp, cmsViewingConditions *vc)
+{
+  vc->whitePoint.X = wp->X;
+  vc->whitePoint.Y = wp->Y;
+  vc->whitePoint.Z = wp->Z;
+  vc->Yb = 20;
+  vc->La = 100;
+  vc->surround = AVG_SURROUND;
+  vc->D_value = 1.0;
+}
+
 /* FIXME: code duplication */
 
 static bool
@@ -160,11 +180,62 @@ parse_xyz_list (Lisp_Object xyz_list, cmsCIEXYZ *color)
   return true;
 }
 
-DEFUN ("lcms-cam02-ucs", Flcms_cam02_ucs, Slcms_cam02_ucs, 2, 3, 0,
+static bool
+parse_viewing_conditions (Lisp_Object view, const cmsCIEXYZ *wp,
+                          cmsViewingConditions *vc)
+{
+#define PARSE_VIEW_CONDITION_FLOAT(field)                              \
+  if (CONSP (view) && NUMBERP (XCAR (view)))                           \
+    {                                                                  \
+      vc->field = XFLOATINT (XCAR (view));                             \
+      view = XCDR (view);                                              \
+    }                                                                  \
+  else                                                                 \
+    return false;
+#define PARSE_VIEW_CONDITION_INT(field)                                        
\
+  if (CONSP (view) && NATNUMP (XCAR (view)))                           \
+    {                                                                  \
+      CHECK_RANGED_INTEGER (XCAR (view), 1, 4);                                
\
+      vc->field = XINT (XCAR (view));                                  \
+      view = XCDR (view);                                              \
+    }                                                                  \
+  else                                                                 \
+    return false;
+
+  PARSE_VIEW_CONDITION_FLOAT (Yb);
+  PARSE_VIEW_CONDITION_FLOAT (La);
+  PARSE_VIEW_CONDITION_INT (surround);
+  PARSE_VIEW_CONDITION_FLOAT (D_value);
+
+  if (! NILP (view))
+    return false;
+
+  vc->whitePoint.X = wp->X;
+  vc->whitePoint.Y = wp->Y;
+  vc->whitePoint.Z = wp->Z;
+  return true;
+}
+
+/* References:
+   Li, Luo et al. "The CRI-CAM02UCS colour rendering index." COLOR research
+   and application, 37 No.3, 2012.
+   Luo et al. "Uniform colour spaces based on CIECAM02 colour appearance
+   model." COLOR research and application, 31 No.4, 2006. */
+
+DEFUN ("lcms-cam02-ucs", Flcms_cam02_ucs, Slcms_cam02_ucs, 2, 4, 0,
        doc: /* Compute CAM02-UCS metric distance between COLOR1 and COLOR2.
-Each color is a list of XYZ coordinates, with Y scaled about unity.
-Optional argument is the XYZ white point, which defaults to illuminant D65.  
*/)
-  (Lisp_Object color1, Lisp_Object color2, Lisp_Object whitepoint)
+Each color is a list of XYZ tristimulus values, with Y scaled about unity.
+Optional argument WHITEPOINT is the XYZ white point, which defaults to
+illuminant D65.
+Optional argument VIEW is a list containing the viewing conditions, and
+is of the form (YB LA SURROUND DVALUE) where SURROUND corresponds to
+  1   AVG_SURROUND
+  2   DIM_SURROUND
+  3   DARK_SURROUND
+  4   CUTSHEET_SURROUND
+The default viewing conditions are (20 100 1 1).  */)
+  (Lisp_Object color1, Lisp_Object color2, Lisp_Object whitepoint,
+   Lisp_Object view)
 {
   cmsViewingConditions vc;
   cmsJCh jch1, jch2;
@@ -188,17 +259,13 @@ Optional argument is the XYZ white point, which defaults 
to illuminant D65.  */)
   if (!(CONSP (color2) && parse_xyz_list (color2, &xyz2)))
     signal_error ("Invalid color", color2);
   if (NILP (whitepoint))
-    parse_xyz_list (Vlcms_d65_xyz, &xyzw);
+    xyzw = illuminant_d65;
   else if (!(CONSP (whitepoint) && parse_xyz_list (whitepoint, &xyzw)))
     signal_error ("Invalid white point", whitepoint);
-
-  vc.whitePoint.X = xyzw.X;
-  vc.whitePoint.Y = xyzw.Y;
-  vc.whitePoint.Z = xyzw.Z;
-  vc.Yb = 20;
-  vc.La = 100;
-  vc.surround = AVG_SURROUND;
-  vc.D_value = 1.0;
+  if (NILP (view))
+    default_viewing_conditions (&xyzw, &vc);
+  else if (!(CONSP (view) && parse_viewing_conditions (view, &xyzw, &vc)))
+    signal_error ("Invalid view conditions", view);
 
   h1 = cmsCIECAM02Init (0, &vc);
   h2 = cmsCIECAM02Init (0, &vc);
@@ -227,10 +294,10 @@ Optional argument is the XYZ white point, which defaults 
to illuminant D65.  */)
   Mp2 = 43.86 * log (1.0 + 0.0228 * (jch2.C * sqrt (sqrt (FL))));
   Jp1 = 1.7 * jch1.J / (1.0 + (0.007 * jch1.J));
   Jp2 = 1.7 * jch2.J / (1.0 + (0.007 * jch2.J));
-  ap1 = Mp1 * cos (jch1.h);
-  ap2 = Mp2 * cos (jch2.h);
-  bp1 = Mp1 * sin (jch1.h);
-  bp2 = Mp2 * sin (jch2.h);
+  ap1 = Mp1 * cos (deg2rad (jch1.h));
+  ap2 = Mp2 * cos (deg2rad (jch2.h));
+  bp1 = Mp1 * sin (deg2rad (jch1.h));
+  bp2 = Mp2 * sin (deg2rad (jch2.h));
 
   return make_float (sqrt ((Jp2 - Jp1) * (Jp2 - Jp1) +
                            (ap2 - ap1) * (ap2 - ap1) +
@@ -291,12 +358,6 @@ DEFUN ("lcms2-available-p", Flcms2_available_p, 
Slcms2_available_p, 0, 0, 0,
 void
 syms_of_lcms2 (void)
 {
-  DEFVAR_LISP ("lcms-d65-xyz", Vlcms_d65_xyz,
-               doc: /* D65 illuminant as a CIE XYZ triple.  */);
-  Vlcms_d65_xyz = list3 (make_float (0.950455),
-                         make_float (1.0),
-                         make_float (1.088753));
-
   defsubr (&Slcms_cie_de2000);
   defsubr (&Slcms_cam02_ucs);
   defsubr (&Slcms2_available_p);
diff --git a/src/nsterm.m b/src/nsterm.m
index 2751533..f0b6a70 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1820,8 +1820,8 @@ x_set_window_size (struct frame *f,
 
   if (pixelwise)
     {
-      pixelwidth = width;
-      pixelheight = height;
+      pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
+      pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
     }
   else
     {
@@ -6498,24 +6498,139 @@ not_in_argv (NSString *arg)
 
   if ([theEvent type] == NSEventTypeScrollWheel)
     {
-      CGFloat delta = [theEvent deltaY];
-      /* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */
-      if (delta == 0)
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+      if ([theEvent respondsToSelector:@selector(hasPreciseScrollingDeltas)])
         {
-          delta = [theEvent deltaX];
-          if (delta == 0)
+#endif
+          /* If the input device is a touchpad or similar, use precise
+           * scrolling deltas.  These are measured in pixels, so we
+           * have to add them up until they exceed one line height,
+           * then we can send a scroll wheel event.
+           *
+           * If the device only has coarse scrolling deltas, like a
+           * real mousewheel, the deltas represent a ratio of whole
+           * lines, so round up the number of lines.  This means we
+           * always send one scroll event per click, but can still
+           * scroll more than one line if the OS tells us to.
+           */
+          bool horizontal;
+          int lines = 0;
+          int scrollUp = NO;
+
+          /* FIXME: At the top or bottom of the buffer we should
+           * ignore momentum-phase events.  */
+          if (! ns_use_mwheel_momentum
+              && [theEvent momentumPhase] != NSEventPhaseNone)
+            return;
+
+          if ([theEvent hasPreciseScrollingDeltas])
             {
-              NSTRACE_MSG ("deltaIsZero");
-              return;
+              static int totalDeltaX, totalDeltaY;
+              int lineHeight;
+
+              if (NUMBERP (ns_mwheel_line_height))
+                lineHeight = XINT (ns_mwheel_line_height);
+              else
+                {
+                  /* FIXME: Use actual line height instead of the default.  */
+                  lineHeight = default_line_pixel_height
+                    (XWINDOW (FRAME_SELECTED_WINDOW (emacsframe)));
+                }
+
+              if ([theEvent phase] == NSEventPhaseBegan)
+                {
+                  totalDeltaX = 0;
+                  totalDeltaY = 0;
+                }
+
+              totalDeltaX += [theEvent scrollingDeltaX];
+              totalDeltaY += [theEvent scrollingDeltaY];
+
+              /* Calculate the number of lines, if any, to scroll, and
+               * reset the total delta for the direction we're NOT
+               * scrolling so that small movements don't add up.  */
+              if (abs (totalDeltaX) > abs (totalDeltaY)
+                  && abs (totalDeltaX) > lineHeight)
+                {
+                  horizontal = YES;
+                  scrollUp = totalDeltaX > 0;
+
+                  lines = abs (totalDeltaX / lineHeight);
+                  totalDeltaX = totalDeltaX % lineHeight;
+                  totalDeltaY = 0;
+                }
+              else if (abs (totalDeltaY) >= abs (totalDeltaX)
+                       && abs (totalDeltaY) > lineHeight)
+                {
+                  horizontal = NO;
+                  scrollUp = totalDeltaY > 0;
+
+                  lines = abs (totalDeltaY / lineHeight);
+                  totalDeltaY = totalDeltaY % lineHeight;
+                  totalDeltaX = 0;
+                }
+
+              if (lines > 1 && ! ns_use_mwheel_acceleration)
+                lines = 1;
             }
-          emacs_event->kind = HORIZ_WHEEL_EVENT;
+          else
+            {
+              CGFloat delta;
+
+              if ([theEvent scrollingDeltaY] == 0)
+                {
+                  horizontal = YES;
+                  delta = [theEvent scrollingDeltaX];
+                }
+              else
+                {
+                  horizontal = NO;
+                  delta = [theEvent scrollingDeltaY];
+                }
+
+              lines = (ns_use_mwheel_acceleration)
+                ? ceil (fabs (delta)) : 1;
+
+              scrollUp = delta > 0;
+            }
+
+          if (lines == 0)
+            return;
+
+          emacs_event->kind = horizontal ? HORIZ_WHEEL_EVENT : WHEEL_EVENT;
+          emacs_event->arg = (make_number (lines));
+
+          emacs_event->code = 0;
+          emacs_event->modifiers = EV_MODIFIERS (theEvent) |
+            (scrollUp ? up_modifier : down_modifier);
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
         }
       else
-        emacs_event->kind = WHEEL_EVENT;
+#endif
+#endif /* defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+        {
+          CGFloat delta = [theEvent deltaY];
+          /* Mac notebooks send wheel events w/delta =0 when trackpad 
scrolling */
+          if (delta == 0)
+            {
+              delta = [theEvent deltaX];
+              if (delta == 0)
+                {
+                  NSTRACE_MSG ("deltaIsZero");
+                  return;
+                }
+              emacs_event->kind = HORIZ_WHEEL_EVENT;
+            }
+          else
+            emacs_event->kind = WHEEL_EVENT;
 
-      emacs_event->code = 0;
-      emacs_event->modifiers = EV_MODIFIERS (theEvent) |
-        ((delta > 0) ? up_modifier : down_modifier);
+          emacs_event->code = 0;
+          emacs_event->modifiers = EV_MODIFIERS (theEvent) |
+            ((delta > 0) ? up_modifier : down_modifier);
+        }
+#endif
     }
   else
     {
@@ -6524,9 +6639,11 @@ not_in_argv (NSString *arg)
       emacs_event->modifiers = EV_MODIFIERS (theEvent)
                              | EV_UDMODIFIERS (theEvent);
     }
+
   XSETINT (emacs_event->x, lrint (p.x));
   XSETINT (emacs_event->y, lrint (p.y));
   EV_TRAILER (theEvent);
+  return;
 }
 
 
@@ -6707,9 +6824,10 @@ not_in_argv (NSString *arg)
 
   if (wait_for_tool_bar)
     {
-      /* The toolbar height is always 0 in fullscreen, so don't wait
-         for it to become available. */
+      /* The toolbar height is always 0 in fullscreen and undecorated
+         frames, so don't wait for it to become available. */
       if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0
+          && FRAME_UNDECORATED (emacsframe) == false
           && ! [self isFullscreen])
         {
           NSTRACE_MSG ("Waiting for toolbar");
@@ -7090,9 +7208,9 @@ not_in_argv (NSString *arg)
 
   win = [[EmacsWindow alloc]
             initWithContentRect: r
-                      styleMask: (FRAME_UNDECORATED (f)
-                                  ? FRAME_UNDECORATED_FLAGS
-                                  : FRAME_DECORATED_FLAGS
+                      styleMask: ((FRAME_UNDECORATED (f)
+                                   ? FRAME_UNDECORATED_FLAGS
+                                   : FRAME_DECORATED_FLAGS)
 #ifdef NS_IMPL_COCOA
                                   | NSWindowStyleMaskResizable
                                   | NSWindowStyleMaskMiniaturizable
@@ -9166,6 +9284,23 @@ Note that this does not apply to images.
 This variable is ignored on Mac OS X < 10.7 and GNUstep.  */);
   ns_use_srgb_colorspace = YES;
 
+  DEFVAR_BOOL ("ns-use-mwheel-acceleration",
+               ns_use_mwheel_acceleration,
+     doc: /*Non-nil means use macOS's standard mouse wheel acceleration.
+This variable is ignored on macOS < 10.7 and GNUstep.  Default is t.  */);
+  ns_use_mwheel_acceleration = YES;
+
+  DEFVAR_LISP ("ns-mwheel-line-height", ns_mwheel_line_height,
+               doc: /*The number of pixels touchpad scrolling considers one 
line.
+Nil or a non-number means use the default frame line height.
+This variable is ignored on macOS < 10.7 and GNUstep.  Default is nil.  */);
+  ns_mwheel_line_height = Qnil;
+
+  DEFVAR_BOOL ("ns-use-mwheel-momentum", ns_use_mwheel_momentum,
+               doc: /*Non-nil means mouse wheel scrolling uses momentum.
+This variable is ignored on macOS < 10.7 and GNUstep.  Default is t.  */);
+  ns_use_mwheel_momentum = YES;
+
   /* TODO: move to common code */
   DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
               doc: /* Which toolkit scroll bars Emacs uses, if any.
diff --git a/src/term.c b/src/term.c
index a2ae8c2..065bce4 100644
--- a/src/term.c
+++ b/src/term.c
@@ -155,12 +155,16 @@ tty_ring_bell (struct frame *f)
 static void
 tty_send_additional_strings (struct terminal *terminal, Lisp_Object sym)
 {
-  Lisp_Object lisp_terminal;
-  Lisp_Object extra_codes;
+  /* Use only accessors like CDR_SAFE and assq_no_quit to avoid any
+     form of quitting or signaling an error, since this function can
+     run as part of the "emergency escape" procedure invoked in the
+     middle of GC, where quitting means crashing (Bug#17406).  */
+  if (! terminal->name)
+    return;
   struct tty_display_info *tty = terminal->display_info.tty;
 
-  XSETTERMINAL (lisp_terminal, terminal);
-  for (extra_codes = Fterminal_parameter (lisp_terminal, sym);
+  for (Lisp_Object extra_codes
+        = CDR_SAFE (assq_no_quit (sym, terminal->param_alist));
        CONSP (extra_codes);
        extra_codes = XCDR (extra_codes))
     {
diff --git a/src/termhooks.h b/src/termhooks.h
index 97c128b..b5171bf 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -116,7 +116,9 @@ enum event_kind
                                   .frame_or_window gives the frame
                                   the wheel event occurred in.
                                   .timestamp gives a timestamp (in
-                                  milliseconds) for the event.  */
+                                  milliseconds) for the event.
+                                   .arg may contain the number of
+                                   lines to scroll.  */
   HORIZ_WHEEL_EVENT,            /* A wheel event generated by a second
                                    horizontal wheel that is present on some
                                    mice. See WHEEL_EVENT.  */
diff --git a/src/xdisp.c b/src/xdisp.c
index dc5dbb0..141275f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22395,8 +22395,8 @@ Value is the new character position of point.  */)
            row += dir;
          else
            row -= dir;
-         if (row < MATRIX_FIRST_TEXT_ROW (w->current_matrix)
-             || row > MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w))
+         if (!(MATRIX_FIRST_TEXT_ROW (w->current_matrix) <= row
+               && row < MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w)))
            goto simulate_display;
 
          if (dir > 0)
diff --git a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el 
b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
new file mode 100644
index 0000000..f52a2b1
--- /dev/null
+++ b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
@@ -0,0 +1,130 @@
+;;; edebug-test-code.el --- Sample code for the Edebug test suite
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Author: Gemini Lasswell
+
+;; 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/>.
+
+;;; Commentary:
+
+;; This file contains sample code used by edebug-tests.el.
+;; Before evaluation, it will be preprocessed by
+;; `edebug-tests-setup-code-file' which will remove all tags
+;; between !'s and save their positions for use by the tests.
+
+;;; Code:
+
+(defun edebug-test-code-fac (n)
+  !start!(if !step!(< 0 n)
+      (* n (edebug-test-code-fac (1- n)))!mult!
+    1))
+
+(defun edebug-test-code-concat (a b flag)
+  !start!(if flag!flag!
+      !then-start!(concat a!then-a! b!then-b!)!then-concat!
+      !else-start!(concat b!else-b! a!else-a!)!else-concat!)!if!)
+
+(defun edebug-test-code-range (num)
+  !start!(let ((index 0)
+        (result nil))
+    (while (< index num)!test!
+      (push index result)!loop!
+      (cl-incf index))!end-loop!
+    (nreverse result)))
+
+(defun edebug-test-code-choices (input)
+  !start!(cond
+   ((eq input 0) "zero")
+   ((eq input 7) 42)
+   (t !edebug!(edebug))))
+
+(defvar edebug-test-code-total nil)
+
+(defun edebug-test-code-multiply (times value)
+  !start!(setq edebug-test-code-total 0)
+  (cl-dotimes (index times)
+    (setq edebug-test-code-total (+ edebug-test-code-total value))!setq!)
+  edebug-test-code-total)
+
+(defun edebug-test-code-format-vector-node (node)
+  !start!(concat "["
+          (apply 'concat (mapcar 'edebug-test-code-format-node node))!apply!
+          "]"))
+
+(defun edebug-test-code-format-list-node (node)
+  !start!(concat "{"
+          (apply 'concat (mapcar 'edebug-test-code-format-node node))!apply!
+          "}"))
+
+(defun edebug-test-code-format-node (node)
+  !start!(cond
+   (!vectorp!(vectorp node!vnode!)!vtest! 
!vbefore!(edebug-test-code-format-vector-node node))
+   ((listp node) (edebug-test-code-format-list-node node))
+   (t (format "%s" node))))
+
+(defvar edebug-test-code-flavor "strawberry")
+
+(defmacro edebug-test-code-with-flavor (new-flavor &rest body)
+   (declare (debug (form body))
+           (indent 1))
+  `(let ((edebug-test-code-flavor ,new-flavor))
+     ,@body))
+
+(defun edebug-test-code-try-flavors ()
+  (let* (tried)
+    (push edebug-test-code-flavor tried)
+    !macro!(edebug-test-code-with-flavor "chocolate"
+      (push edebug-test-code-flavor tried))
+    tried)!end!)
+
+(unless (featurep 'edebug-tests-nutty)!nutty!
+   !setq!(setq edebug-test-code-flavor (car 
(edebug-test-code-try-flavors)))!end-setq!)!end-unless!
+
+(cl-defgeneric edebug-test-code-emphasize (x))
+(cl-defmethod edebug-test-code-emphasize ((x integer))
+  !start!(format "The number is not %s or %s, but %s!"
+                 (1+ x) (1- x) x))
+(cl-defmethod edebug-test-code-emphasize ((x string))
+  !start!(format "***%s***" x))
+
+(defun edebug-test-code-use-methods ()
+  (list
+   !number!(edebug-test-code-emphasize 100)
+   !string!(edebug-test-code-emphasize "yes")))
+
+(defun edebug-test-code-make-lambda (n)
+  (lambda (x) (+ x!x! n)))
+
+(defun edebug-test-code-use-lambda ()
+  !start!(mapcar (edebug-test-code-make-lambda 10) '(1 2 3)))
+
+(defun edebug-test-code-circular-read-syntax ()
+  '(#1=a . #1#))
+
+(defun edebug-test-code-hash-read-syntax ()
+  !start!(list #("abcd" 1 3 (face italic))
+        #x01ff))
+
+(defun edebug-test-code-empty-string-list ()
+  !start!(list "")!step!)
+
+(defun edebug-test-code-current-buffer ()
+  !start!(with-current-buffer (get-buffer-create "*edebug-test-code-buffer*")
+    !body!(format "current-buffer: %s" (current-buffer))))
+
+(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
new file mode 100644
index 0000000..02f4d1c
--- /dev/null
+++ b/test/lisp/emacs-lisp/edebug-tests.el
@@ -0,0 +1,903 @@
+;;; edebug-tests.el --- Edebug test suite   -*- lexical-binding:t -*-
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Author: Gemini Lasswell
+
+;; 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/>.
+
+;;; Commentary:
+
+;; These tests focus on Edebug's user interface for setting
+;; breakpoints, stepping through and tracing code, and evaluating
+;; values used by the code.  In addition there are some tests of
+;; Edebug's reader.  There are large parts of Edebug's functionality
+;; not covered by these tests, including coverage testing, macro
+;; specifications, and the eval list buffer.
+
+;;; Code:
+
+(require 'cl-lib)
+(require 'ert)
+(require 'ert-x)
+(require 'edebug)
+(require 'kmacro)
+
+;; Use `eval-and-compile' because this is used by the macro
+;; `edebug-tests-deftest'.
+(eval-and-compile
+  (defvar edebug-tests-sample-code-file
+    (expand-file-name
+     "edebug-resources/edebug-test-code.el"
+     (file-name-directory (or (bound-and-true-p byte-compile-current-file)
+                              load-file-name
+                              buffer-file-name)))
+    "Name of file containing code samples for Edebug tests."))
+
+(defvar edebug-tests-temp-file nil
+  "Name of temp file containing sample code stripped of stop point symbols.")
+(defvar edebug-tests-stop-points nil
+  "An alist of alists mapping function symbol -> stop point name -> marker.
+Used by the tests to refer to locations in `edebug-tests-temp-file'.")
+(defvar edebug-tests-messages nil
+  "Messages collected during execution of the current test.")
+
+(defvar address@hidden 'no-result
+  "Return value of `edebug-tests-func', or no-result if there isn't one yet.")
+
+(defvar edebug-tests-failure-in-post-command nil
+  "An error trapped in `edebug-tests-post-command'.
+Since `should' failures which happen inside `post-command-hook' will
+be trapped by the command loop, this preserves them until we get
+back to the top level.")
+
+(defvar edebug-tests-keymap
+  (let ((map (make-sparse-keymap)))
+    (define-key map "@"     'edebug-tests-call-instrumented-func)
+    (define-key map "C-u"   'universal-argument)
+    (define-key map "C-p"   'previous-line)
+    (define-key map "C-n"   'next-line)
+    (define-key map "C-b"   'backward-char)
+    (define-key map "C-a"   'move-beginning-of-line)
+    (define-key map "C-e"   'move-end-of-line)
+    (define-key map "C-k"   'kill-line)
+    (define-key map "M-x"   'execute-extended-command)
+    (define-key map "C-M-x" 'eval-defun)
+    (define-key map "C-x X b" 'edebug-set-breakpoint)
+    (define-key map "C-x X w" 'edebug-where)
+    map)
+  "Keys used by the keyboard macros in Edebug's tests.")
+
+;;; Macros for defining tests:
+
+(defmacro edebug-tests-with-default-config (&rest body)
+  "Create a consistent environment for an Edebug test BODY to run in."
+  (declare (debug (body)))
+  `(cl-letf* (
+              ;; These defcustoms are set to their original value.
+              (edebug-setup-hook nil)
+              (edebug-all-defs nil)
+              (edebug-all-forms nil)
+              (edebug-eval-macro-args nil)
+              (edebug-save-windows t)
+              (edebug-save-displayed-buffer-points nil)
+              (edebug-initial-mode 'step)
+              (edebug-trace nil)
+              (edebug-test-coverage nil)
+              (edebug-print-length 50)
+              (edebug-print-level 50)
+              (edebug-print-circle t)
+              (edebug-unwrap-results nil)
+              (edebug-on-error t)
+              (edebug-on-quit t)
+              (edebug-global-break-condition nil)
+              (edebug-sit-for-seconds 1)
+
+              ;; sit-on interferes with keyboard macros.
+              (edebug-sit-on-break nil)
+              (edebug-continue-kbd-macro t))
+     ,@body))
+
+(defmacro edebug-tests-with-normal-env (&rest body)
+  "Set up the environment for an Edebug test BODY, run it, and clean up."
+  (declare (debug (body)))
+  `(edebug-tests-with-default-config
+    (let ((edebug-tests-failure-in-post-command nil)
+          (edebug-tests-temp-file (make-temp-file "edebug-tests-" nil ".el")))
+      (edebug-tests-setup-code-file edebug-tests-temp-file)
+      (ert-with-message-capture
+       edebug-tests-messages
+       (unwind-protect
+           (with-current-buffer (find-file edebug-tests-temp-file)
+             (read-only-mode)
+             (setq lexical-binding t)
+             (eval-buffer)
+             ,@body
+             (when edebug-tests-failure-in-post-command
+               (signal (car edebug-tests-failure-in-post-command)
+                       (cdr edebug-tests-failure-in-post-command))))
+         (unload-feature 'edebug-test-code)
+         (with-current-buffer (find-file-noselect edebug-tests-temp-file)
+           (set-buffer-modified-p nil))
+         (ignore-errors (kill-buffer (find-file-noselect
+                                      edebug-tests-temp-file)))
+         (ignore-errors (delete-file edebug-tests-temp-file)))))))
+
+;; The following macro and its support functions implement an extension
+;; to keyboard macros to allow interleaving of keyboard macro
+;; events with evaluation of Lisp expressions. The Lisp expressions
+;; are called from within `post-command-hook', which is a strategy
+;; inspired by `kmacro-step-edit-macro'.
+
+;; Some of the details necessary to get this to work with Edebug are:
+;; -- ERT's `should' macros raise errors, and errors within
+;;    `post-command-hook' are trapped by the command loop. The
+;;    workaround is to trap and save an error inside the hook
+;;    function and reraise it after the macro exits.
+;; -- `edebug-continue-kbd-macro' must be non-nil.
+;; -- Edebug calls `exit-recursive-edit' which turns off keyboard
+;;    macro execution. Solved with an advice wrapper for
+;;    `exit-recursive-edit' which preserves the keyboard macro state.
+
+(defmacro edebug-tests-run-kbd-macro (&rest macro)
+  "Run a MACRO consisting of both keystrokes and test assertions.
+MACRO should be a list, where each item is either a keyboard
+macro segment (in string or vector form) or a Lisp expression.
+Convert the macro segments into keyboard macros and execute them.
+After the execution of the last event of each segment, evaluate
+the Lisp expressions following the segment."
+  (let ((prepared (edebug-tests-prepare-macro macro)))
+    `(edebug-tests-run-macro ,@prepared)))
+
+;; Make support functions for edebug-tests-run-kbd-macro
+;; available at compile time.
+(eval-and-compile
+  (defun edebug-tests-prepare-macro (macro)
+    "Prepare a MACRO for execution.
+MACRO should be a list containing strings, vectors, and Lisp
+forms. Convert the strings and vectors to keyboard macros in
+vector representation and concatenate them to make a single
+keyboard macro.  Also build a list of the same length as the
+number of events in the keyboard macro.  Each item in that list
+will contain the code to evaluate after the corresponding event
+in the keyboard macro, either nil or a thunk built from the forms
+in the original list.  Return a list containing the keyboard
+macro as the first item, followed by the list of thunks and/or
+nils."
+    (cl-loop
+     for item = (pop macro)
+     while item
+     for segment = (read-kbd-macro item)
+     for thunk = (edebug-tests-wrap-thunk
+                  (cl-loop
+                   for form in macro
+                   until (or (stringp form) (vectorp form))
+                   collect form
+                   do (pop macro)))
+     vconcat segment into segments
+     append (edebug-tests-pad-thunk-list (length segment) thunk)
+      into thunk-list
+
+     finally return (cons segments thunk-list)))
+
+  (defun edebug-tests-wrap-thunk (body)
+    "If BODY is non-nil, wrap it with a lambda form."
+    (when body
+      `(lambda () ,@body)))
+
+  (defun edebug-tests-pad-thunk-list (length thunk)
+    "Return a list with LENGTH elements with THUNK in the last position.
+All other elements will be nil."
+    (let ((thunk-seg (make-list length nil)))
+      (setf (car (last thunk-seg)) thunk)
+      thunk-seg)))
+
+;;; Support for test execution:
+
+(defvar edebug-tests-thunks nil
+  "List containing thunks to run after each command in a keyboard macro.")
+(defvar edebug-tests-kbd-macro-index nil
+  "Index into `edebug-tests-run-unpacked-kbd-macro's current keyboard macro.")
+
+(defun edebug-tests-run-macro (kbdmac &rest thunks)
+  "Run a keyboard macro and execute a thunk after each command in it.
+KBDMAC should be a vector of events and THUNKS a list of the
+same length containing thunks and/or nils.  Run the macro, and
+after the execution of every command in the macro (which may not
+be the same as every keystroke) execute the thunk at the same
+index."
+  (let* ((edebug-tests-thunks thunks)
+         (edebug-tests-kbd-macro-index 0)
+         saved-local-map)
+    (with-current-buffer (find-file-noselect edebug-tests-temp-file)
+      (setq saved-local-map overriding-local-map)
+      (setq overriding-local-map edebug-tests-keymap)
+      (add-hook 'post-command-hook 'edebug-tests-post-command))
+    (advice-add 'exit-recursive-edit
+                :around 'edebug-tests-preserve-keyboard-macro-state)
+    (unwind-protect
+        (kmacro-call-macro nil nil nil kbdmac)
+      (advice-remove 'exit-recursive-edit
+                     'edebug-tests-preserve-keyboard-macro-state)
+      (with-current-buffer (find-file-noselect edebug-tests-temp-file)
+        (setq overriding-local-map saved-local-map)
+        (remove-hook 'post-command-hook 'edebug-tests-post-command)))))
+
+(defun edebug-tests-preserve-keyboard-macro-state (orig &rest args)
+  "Call ORIG with ARGS preserving the value of `executing-kbd-macro'.
+Useful to prevent `exit-recursive-edit' from stopping the current
+keyboard macro."
+  (let ((executing-kbd-macro executing-kbd-macro))
+    (apply orig args)))
+
+(defun edebug-tests-post-command ()
+  "Run the thunk from `edebug-tests-thunks' matching the keyboard macro index."
+  (when (and edebug-tests-kbd-macro-index
+             (> executing-kbd-macro-index edebug-tests-kbd-macro-index))
+    (let ((thunk (nth (1- executing-kbd-macro-index) edebug-tests-thunks)))
+      (when thunk
+        (condition-case err
+            (funcall thunk)
+          (error
+           (setq edebug-tests-failure-in-post-command err)
+           (signal (car err) (cdr err)))))
+      (setq edebug-tests-kbd-macro-index executing-kbd-macro-index))))
+
+(defvar edebug-tests-func nil
+  "Instrumented function used to launch Edebug.")
+(defvar edebug-tests-args nil
+  "Arguments for `edebug-tests-func'.")
+
+(defun edebug-tests-setup-@ (def-name args edebug-it)
+  "Set up the binding for @ in `edebug-tests-keymap'.
+Find a definition for DEF-NAME in the current buffer and evaluate it.
+Set globals so that `edebug-tests-call-instrumented-func' which
+is bound to @ for edebug-tests' keyboard macros will call it with
+ARGS.  EDEBUG-IT is passed through to `eval-defun'."
+  (edebug-tests-locate-def def-name)
+  (eval-defun edebug-it)
+  (let* ((full-name (concat "edebug-test-code-" def-name))
+         (sym (intern-soft full-name)))
+    (should (and sym (fboundp sym)))
+    (setq edebug-tests-func sym
+          edebug-tests-args args)
+    (setq address@hidden 'no-result)))
+
+(defun edebug-tests-call-instrumented-func ()
+  "Call `edebug-tests-func' with `edebug-tests-args' and save the results."
+  (interactive)
+  (let ((result (apply edebug-tests-func edebug-tests-args)))
+    (should (eq address@hidden 'no-result))
+    (setq address@hidden result)))
+
+(defun edebug-tests-should-be-at (def-name point-name)
+  "Require that point be at the location in DEF-NAME named POINT-NAME.
+DEF-NAME should be the suffix of a definition in the code samples
+file (the part after \"edebug-tests\")."
+  (let ((stop-point (edebug-tests-get-stop-point def-name point-name)))
+    (should (eq (current-buffer) (find-file-noselect edebug-tests-temp-file)))
+    (should (eql (point) stop-point))))
+
+(defun edebug-tests-get-stop-point (def-name point-name)
+  "Return the position in DEF-NAME of the stop point named POINT-NAME.
+DEF-NAME should be the suffix of a definition in the code samples
+file (the part after \"edebug-tests\")."
+  (let* ((full-name (concat "edebug-test-code-" def-name))(stop-point
+         (cdr (assoc point-name
+                     (cdr (assoc full-name edebug-tests-stop-points))))))
+    (unless stop-point
+      (ert-fail (format "%s not found in %s" point-name full-name)))
+    stop-point))
+
+(defun edebug-tests-should-match-result-in-messages (value)
+  "Require that VALUE (a string) match an Edebug result in *Messages*.
+Then clear edebug-tests' saved messages."
+  (should (string-match-p (concat "Result: " (regexp-quote value) "$")
+                          edebug-tests-messages))
+  (setq edebug-tests-messages ""))
+
+(defun edebug-tests-locate-def (def-name)
+  "Search for a definition of DEF-NAME from the start of the current buffer.
+Place point at the end of DEF-NAME in the buffer."
+  (goto-char (point-min))
+  (re-search-forward (concat "def\\S-+ edebug-test-code-" def-name)))
+
+(defconst edebug-tests-start-of-next-def-regexp "^(\\S-*def\\S-+ \\(\\S-+\\)"
+  "Regexp used to match the start of a definition.")
+(defconst edebug-tests-stop-point-regexp "!\\(\\S-+?\\)!"
+  "Regexp used to match a stop point annotation in the sample code.")
+
+;;; Set up buffer containing code samples:
+
+(defmacro edebug-tests-deduplicate (name names-and-numbers)
+  "Return a unique variation on NAME.
+NAME should be a string and NAMES-AND-NUMBERS an alist which can
+be used by this macro to retain state.  If NAME for example is
+\"symbol\" then the first and subsequent uses of this macro will
+evaluate to \"symbol\", \"symbol-1\", \"symbol-2\", etc."
+  (let ((g-name (gensym))
+        (g-duplicate (gensym)))
+    `(let* ((,g-name ,name)
+            (,g-duplicate (assoc ,g-name ,names-and-numbers)))
+       (if (null ,g-duplicate)
+           (progn
+             (push (cons ,g-name 0) ,names-and-numbers)
+             ,g-name)
+         (cl-incf (cdr ,g-duplicate))
+         (format "%s-%s" ,g-name (cdr ,g-duplicate))))))
+
+(defun edebug-tests-setup-code-file (tmpfile)
+  "Extract stop points and loadable code from the sample code file.
+Write the loadable code to a buffer for TMPFILE, and set
+`edebug-tests-stop-points' to a map from defined symbols to stop
+point names to positions in the file."
+  (with-current-buffer (find-file-noselect edebug-tests-sample-code-file)
+    (let ((marked-up-code (buffer-string)))
+      (with-temp-file tmpfile
+        (insert marked-up-code))))
+
+  (with-current-buffer (find-file-noselect tmpfile)
+    (let ((stop-points
+           ;; Delete all the !name! annotations from the code, but remember
+           ;; their names and where they were in an alist.
+           (cl-loop
+            initially (goto-char (point-min))
+            while (re-search-forward edebug-tests-stop-point-regexp nil t)
+            for name = (match-string-no-properties 1)
+            do (replace-match "")
+            collect (cons name (point))))
+          names-and-numbers)
+
+      ;; Now build an alist mapping definition names to annotation
+      ;; names and positions.
+      ;; If duplicate symbols exist in the file, enter them in the
+      ;; alist as symbol, symbol-1, symbol-2 etc.
+      (setq edebug-tests-stop-points
+            (cl-loop
+             initially (goto-char (point-min))
+             while (re-search-forward edebug-tests-start-of-next-def-regexp
+                                      nil t)
+             for name =
+               (edebug-tests-deduplicate (match-string-no-properties 1)
+                                   names-and-numbers)
+             for end-of-def =
+               (save-match-data
+                 (save-excursion
+                   (re-search-forward edebug-tests-start-of-next-def-regexp
+                                      nil 0)
+                   (point)))
+             collect (cons name
+                           (cl-loop
+                            while (and stop-points
+                                       (< (cdar stop-points) end-of-def))
+                            collect (pop stop-points))))))))
+
+;;; Tests
+
+(ert-deftest edebug-tests-check-keymap ()
+  "Verify that `edebug-mode-map' is compatible with these tests.
+If this test fails, one of two things is true. Either your
+customizations modify `edebug-mode-map', in which case starting
+Emacs with the -Q flag should fix the problem, or
+`edebug-mode-map' has changed in edebug.el, in which case this
+test and possibly others should be updated."
+  ;; The reason verify-keybinding is a macro instead of a function is
+  ;; that in the event of a failure, it makes the keybinding that
+  ;; failed show up in ERT's output.
+  (cl-macrolet ((verify-keybinding (key binding)
+                   `(should (eq (lookup-key edebug-mode-map ,key)
+                                ,binding))))
+    (verify-keybinding " " 'edebug-step-mode)
+    (verify-keybinding "n" 'edebug-next-mode)
+    (verify-keybinding "g" 'edebug-go-mode)
+    (verify-keybinding "G" 'edebug-Go-nonstop-mode)
+    (verify-keybinding "t" 'edebug-trace-mode)
+    (verify-keybinding "T" 'edebug-Trace-fast-mode)
+    (verify-keybinding "c" 'edebug-continue-mode)
+    (verify-keybinding "C" 'edebug-Continue-fast-mode)
+    (verify-keybinding "f" 'edebug-forward-sexp)
+    (verify-keybinding "h" 'edebug-goto-here)
+    (verify-keybinding "I" 'edebug-instrument-callee)
+    (verify-keybinding "i" 'edebug-step-in)
+    (verify-keybinding "o" 'edebug-step-out)
+    (verify-keybinding "q" 'top-level)
+    (verify-keybinding "Q" 'edebug-top-level-nonstop)
+    (verify-keybinding "a" 'abort-recursive-edit)
+    (verify-keybinding "S" 'edebug-stop)
+    (verify-keybinding "b" 'edebug-set-breakpoint)
+    (verify-keybinding "u" 'edebug-unset-breakpoint)
+    (verify-keybinding "B" 'edebug-next-breakpoint)
+    (verify-keybinding "x" 'edebug-set-conditional-breakpoint)
+    (verify-keybinding "X" 'edebug-set-global-break-condition)
+    (verify-keybinding "r" 'edebug-previous-result)
+    (verify-keybinding "e" 'edebug-eval-expression)
+    (verify-keybinding "\C-x\C-e" 'edebug-eval-last-sexp)
+    (verify-keybinding "E" 'edebug-visit-eval-list)
+    (verify-keybinding "w" 'edebug-where)
+    (verify-keybinding "v" 'edebug-view-outside) ;; maybe obsolete??
+    (verify-keybinding "p" 'edebug-bounce-point)
+    (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 "-" 'negative-argument)
+    (verify-keybinding "=" 'edebug-temp-display-freq-count)))
+
+(ert-deftest edebug-tests-stop-point-at-start-of-first-instrumented-function ()
+  "Edebug stops at the beginning of an instrumented function."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "fac" '(0) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "fac" "start")
+    "SPC" (edebug-tests-should-be-at "fac" "step")
+    "g"   (should (equal address@hidden 1)))))
+
+(ert-deftest edebug-tests-step-showing-evaluation-results ()
+  "Edebug prints expression evaluation results to the echo area."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "concat" '("x" "y" nil) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "concat" "start")
+    "SPC" (edebug-tests-should-be-at "concat" "flag")
+    (edebug-tests-should-match-result-in-messages "nil")
+    "SPC" (edebug-tests-should-be-at "concat" "else-start")
+    "SPC" (edebug-tests-should-be-at "concat" "else-b")
+    (edebug-tests-should-match-result-in-messages "\"y\"")
+    "SPC" (edebug-tests-should-be-at "concat" "else-a")
+    (edebug-tests-should-match-result-in-messages "\"x\"")
+    "SPC" (edebug-tests-should-be-at "concat" "else-concat")
+    (edebug-tests-should-match-result-in-messages "\"yx\"")
+    "SPC" (edebug-tests-should-be-at "concat" "if")
+    (edebug-tests-should-match-result-in-messages "\"yx\"")
+    "SPC" (should (equal address@hidden "yx")))))
+
+(ert-deftest edebug-tests-set-breakpoint-at-point ()
+  "Edebug can set a breakpoint at point."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "concat" '("x" "y" t) t)
+   (edebug-tests-run-kbd-macro
+    "@"  (edebug-tests-should-be-at "concat" "start")
+    "C-n C-e b C-n"  ; Move down, set a breakpoint and move away.
+    "g"  (edebug-tests-should-be-at "concat" "then-concat")
+    (edebug-tests-should-match-result-in-messages "\"xy\"")
+    "g"  (should (equal address@hidden "xy")))))
+
+(ert-deftest edebug-tests-set-temporary-breakpoint-at-point ()
+  "Edebug can set a temporary breakpoint at point."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "range" '(3) t)
+   (edebug-tests-run-kbd-macro
+    "@" (edebug-tests-should-be-at "range" "start")
+    "C-n C-n C-n C-e"     ; Move down to the end of a sexp in the loop.
+    "C-u b"               ; Set a temporary breakpoint.
+    "C-n"                 ; Move away.
+    "g"   (edebug-tests-should-be-at "range" "loop")
+    (edebug-tests-should-match-result-in-messages "(0)")
+    "g" (should (equal address@hidden '(0 1 2))))))
+
+(ert-deftest edebug-tests-clear-breakpoint ()
+  "Edebug can clear a breakpoint."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "range" '(3) t)
+   (edebug-tests-run-kbd-macro
+    "@"
+    (message "after @")
+    (edebug-tests-should-be-at "range" "start")
+    "C-n C-n C-n C-e b C-n"  ; Move down, set a breakpoint and move away.
+    "g"   (edebug-tests-should-be-at "range" "loop")
+    (edebug-tests-should-match-result-in-messages "(0)")
+    "g"   (edebug-tests-should-be-at "range" "loop")
+    (edebug-tests-should-match-result-in-messages "(1 0)")
+    "u"  ; Unset the breakpoint.
+    "g"   (should (equal address@hidden '(0 1 2))))))
+
+(ert-deftest edebug-tests-move-point-to-next-breakpoint ()
+  "Edebug can move point to the next breakpoint."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "concat" '("a" "b" nil) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "concat" "start")
+    "C-n C-e b"      ; Move down, set a breakpoint.
+    "C-n b"          ; Set another breakpoint on the next line.
+    "C-p C-p C-p"    ; Move back up.
+    "B"   (edebug-tests-should-be-at "concat" "then-concat")
+    "B"   (edebug-tests-should-be-at "concat" "else-concat")
+    "G"   (should (equal address@hidden "ba")))))
+
+(ert-deftest edebug-tests-move-point-back-to-stop-point ()
+  "Edebug can move point back to a stop point."
+  (edebug-tests-with-normal-env
+   (let ((test-buffer (get-buffer-create "edebug-tests-temp")))
+     (edebug-tests-setup-@ "fac" '(4) t)
+     (edebug-tests-run-kbd-macro
+      "@"        (edebug-tests-should-be-at "fac" "start")
+      "C-n w"    (edebug-tests-should-be-at "fac" "start")
+      (pop-to-buffer test-buffer)
+      "C-x X w"  (edebug-tests-should-be-at "fac" "start")
+      "g"        (should (equal address@hidden 24)))
+     (ignore-errors (kill-buffer test-buffer)))))
+
+(ert-deftest edebug-tests-jump-to-point ()
+  "Edebug can stop at a temporary breakpoint at point."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "range" '(3) t)
+   (edebug-tests-run-kbd-macro
+    "@" (edebug-tests-should-be-at "range" "start")
+    "C-n C-n C-n C-e"     ; Move down to the end of a sexp in the loop.
+    "h" (edebug-tests-should-be-at "range" "loop")
+    (edebug-tests-should-match-result-in-messages "(0)")
+    "g" (should (equal address@hidden '(0 1 2))))))
+
+(ert-deftest edebug-tests-jump-forward-one-sexp ()
+  "Edebug can run the program for one expression."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "range" '(3) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "range" "start")
+    "SPC SPC f" (edebug-tests-should-be-at "range" "test")
+    "g"   (should (equal address@hidden '(0 1 2))))))
+
+(ert-deftest edebug-tests-run-out-of-containing-sexp ()
+  "Edebug can run the program until the end of the containing sexp."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "range" '(3) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "range" "start")
+    "SPC SPC f" (edebug-tests-should-be-at "range" "test")
+    "o"   (edebug-tests-should-be-at "range" "end-loop")
+    (edebug-tests-should-match-result-in-messages "nil")
+    "g"   (should (equal address@hidden '(0 1 2))))))
+
+(ert-deftest edebug-tests-observe-breakpoint-in-source ()
+  "Edebug will stop at a breakpoint embedded in source code."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "choices" '(8) t)
+   (edebug-tests-run-kbd-macro
+    "@"  (edebug-tests-should-be-at "choices" "start")
+    "g"  (edebug-tests-should-be-at "choices" "edebug")
+    "g"  (should (equal address@hidden nil)))))
+
+(ert-deftest edebug-tests-set-conditional-breakpoint ()
+  "Edebug can set and observe a conditional breakpoint."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "fac" '(5) t)
+   (edebug-tests-run-kbd-macro
+    "@"  (edebug-tests-should-be-at "fac" "start")
+    ;; Set conditional breakpoint at end of next line.
+    "C-n C-e x (eql SPC n SPC 3) RET"
+    "g"  (edebug-tests-should-be-at "fac" "mult")
+    (edebug-tests-should-match-result-in-messages "6 (#o6, #x6, ?\\C-f)")
+    "g"  (should (equal address@hidden 120)))))
+
+(ert-deftest edebug-tests-error-trying-to-set-breakpoint-in-uninstrumented-code
+    ()
+  "Edebug refuses to set a breakpoint in uninstrumented code."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "fac" '(5) t)
+   (let* ((debug-on-error nil)
+          (edebug-on-error nil)
+          error-message
+          (command-error-function (lambda (&rest args)
+                                    (setq error-message (cadar args)))))
+     (edebug-tests-run-kbd-macro
+      "@"  (edebug-tests-should-be-at "fac" "start")
+      "C-u 10 C-n" ; Move down and out of instrumented function.
+      "b"  (should (string-match-p "Not inside instrumented form"
+                                   error-message))
+      ;; The error stopped the keyboard macro. Start it again.
+      (should-not executing-kbd-macro)
+      (setq executing-kbd-macro t)
+      "g"))))
+
+(ert-deftest edebug-tests-set-and-break-on-global-condition ()
+  "Edebug can break when a global condition becomes true."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "multiply" '(5 3) t)
+   (edebug-tests-run-kbd-macro
+    "@"  (edebug-tests-should-be-at "multiply" "start")
+    "X (> SPC edebug-test-code-total SPC 10) RET"
+    (should edebug-global-break-condition)
+    "g"  (edebug-tests-should-be-at "multiply" "setq")
+    (should (eql (symbol-value 'edebug-test-code-total) 12))
+    "X C-a C-k nil RET" ; Remove suggestion before entering nil.
+    "g"  (should (equal address@hidden 15)))))
+
+(ert-deftest edebug-tests-trace-showing-results-at-stop-points ()
+  "Edebug can trace execution, showing results at stop points."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "concat" '("x" "y" nil) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "concat" "start")
+    "T"   (should (string-match-p
+                   (concat "Result: nil\n.*?"
+                           "Result: \"y\"\n.*?"
+                           "Result: \"x\"\n.*?"
+                           "Result: \"yx\"\n.*?"
+                           "Result: \"yx\"\n")
+                   edebug-tests-messages))
+    (should (equal address@hidden "yx")))))
+
+(ert-deftest edebug-tests-trace-showing-results-at-breakpoints ()
+  "Edebug can trace execution, showing results at breakpoints."
+  (edebug-tests-with-normal-env
+   (edebug-tests-locate-def "format-vector-node")
+   (edebug-tests-run-kbd-macro "C-u C-M-x C-n C-n C-e C-x X b")
+   (edebug-tests-locate-def "format-list-node")
+   (edebug-tests-run-kbd-macro "C-u C-M-x C-n C-n C-e C-x X b")
+   (edebug-tests-setup-@ "format-node" '(([a b] [c d])) t)
+   (edebug-tests-run-kbd-macro
+    "@" (edebug-tests-should-be-at "format-node" "start")
+    "C" (should (string-match-p
+                 (concat "Result: \"ab\"\n.*?"
+                         "Result: \"cd\"\n.*?"
+                         "Result: \"\\[ab]\\[cd]\"\n")
+                 edebug-tests-messages))
+    (should (equal address@hidden "{[ab][cd]}")))))
+
+(ert-deftest edebug-tests-trace-function-call-and-return ()
+  "Edebug can create a trace of function calls and returns."
+  (edebug-tests-with-normal-env
+   (edebug-tests-locate-def "format-vector-node")
+   (eval-defun t)
+   (edebug-tests-locate-def "format-list-node")
+   (eval-defun t)
+   (edebug-tests-setup-@ "format-node" '((a [b])) t)
+   (let ((edebug-trace t)
+         (trace-start (with-current-buffer
+                          (get-buffer-create edebug-trace-buffer) 
(point-max))))
+     (edebug-tests-run-kbd-macro
+      "@"   (edebug-tests-should-be-at "format-node" "start")
+      "g"   (should (equal address@hidden "{a[b]}")))
+     (with-current-buffer edebug-trace-buffer
+       (should (string=
+                "{ edebug-test-code-format-node args: ((a [b]))
+:{ edebug-test-code-format-list-node args: ((a [b]))
+::{ edebug-test-code-format-node args: (a)
+::} edebug-test-code-format-node result: a
+::{ edebug-test-code-format-node args: ([b])
+:::{ edebug-test-code-format-vector-node args: ([b])
+::::{ edebug-test-code-format-node args: (b)
+::::} edebug-test-code-format-node result: b
+:::} edebug-test-code-format-vector-node result: [b]
+::} edebug-test-code-format-node result: [b]
+:} edebug-test-code-format-list-node result: {a[b]}
+} edebug-test-code-format-node result: {a[b]}
+"  (buffer-substring trace-start (point-max))))))))
+
+(ert-deftest edebug-tests-evaluate-expressions ()
+  "Edebug can evaluate an expression in the context outside of itself."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "range" '(2) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "range" "start")
+    "SPC SPC f" (edebug-tests-should-be-at "range" "test")
+    (edebug-tests-should-match-result-in-messages "t")
+    "e (- SPC num SPC index) RET"
+    ;; Edebug just prints the result without "Result:"
+    (should (string-match-p
+             (regexp-quote "2 (#o2, #x2, ?\\C-b)")
+             edebug-tests-messages))
+    "g"   (should (equal address@hidden '(0 1))))
+
+   ;; Do it again with lexical-binding turned off.
+   (setq lexical-binding nil)
+   (eval-buffer)
+   (should-not lexical-binding)
+   (edebug-tests-setup-@ "range" '(2) t)
+   (edebug-tests-run-kbd-macro
+    "@"   (edebug-tests-should-be-at "range" "start")
+    "SPC SPC f" (edebug-tests-should-be-at "range" "test")
+    (edebug-tests-should-match-result-in-messages "t")
+    "e (- SPC num SPC index) RET"
+    ;; Edebug just prints the result without "Result:"
+    (should (string-match-p
+             (regexp-quote "2 (#o2, #x2, ?\\C-b)")
+             edebug-tests-messages))
+    "g"   (should (equal address@hidden '(0 1))))))
+
+(ert-deftest edebug-tests-step-into-function ()
+  "Edebug can step into a function."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "format-node" '([b]) t)
+   (edebug-tests-run-kbd-macro
+    "@"    (edebug-tests-should-be-at "format-node" "start")
+    "SPC SPC SPC SPC"
+    (edebug-tests-should-be-at "format-node" "vbefore")
+    "i"    (edebug-tests-should-be-at "format-vector-node" "start")
+    "g"    (should (equal address@hidden "[b]")))))
+
+(ert-deftest edebug-tests-error-stepping-into-subr ()
+  "Edebug refuses to step into a C function."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "format-node" '([b]) t)
+   (let* ((debug-on-error nil)
+          (edebug-on-error nil)
+          error-message
+          (command-error-function (lambda (&rest args)
+                                    (setq error-message (cl-cadar args)))))
+     (edebug-tests-run-kbd-macro
+      "@"    (edebug-tests-should-be-at "format-node" "start")
+      "SPC"  (edebug-tests-should-be-at "format-node" "vectorp")
+      "i"    (should (string-match-p "vectorp is a built-in function"
+                                     error-message))
+      ;; The error stopped the keyboard macro. Start it again.
+      (should-not executing-kbd-macro)
+      (setq executing-kbd-macro t)
+      "g"    (should (equal address@hidden "[b]"))))))
+
+(ert-deftest edebug-tests-step-into-macro-error ()
+  "Edebug gives an error on trying to step into a macro (Bug#26847)."
+  :expected-result :failed
+  (ert-fail "Forcing failure because letting this test run aborts the others.")
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "try-flavors" nil t)
+   (let* ((debug-on-error nil)
+          (edebug-on-error nil)
+          (error-message "")
+          (command-error-function (lambda (&rest args)
+                                    (setq error-message (cl-cadar args)))))
+     (edebug-tests-run-kbd-macro
+      "@ SPC SPC SPC SPC SPC"
+      (edebug-tests-should-be-at "try-flavors" "macro")
+      "i" (should (string-match-p "edebug-test-code-try-flavors is a macro"
+                                  error-message))
+      ;; The error stopped the keyboard macro. Start it again.
+      (should-not executing-kbd-macro)
+      (setq executing-kbd-macro t)
+      "g"   (should (equal address@hidden
+                           '("chocolate" "strawberry")))))))
+
+(ert-deftest edebug-tests-step-into-generic-method ()
+  "Edebug can step into a generic method (Bug#22294)."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "use-methods" nil t)
+   (edebug-tests-run-kbd-macro
+    "@ SPC" (edebug-tests-should-be-at "use-methods" "number")
+    "i"     (edebug-tests-should-be-at "emphasize-1" "start")
+    "gg"    (should (equal address@hidden
+                           '("The number is not 101 or 99, but 100!"
+                             "***yes***"))))))
+
+(ert-deftest edebug-tests-break-in-lambda-out-of-defining-context ()
+  "Edebug observes a breakpoint in a lambda executed out of defining context."
+  (edebug-tests-with-normal-env
+   (edebug-tests-locate-def "make-lambda")
+   (eval-defun t)
+   (goto-char (edebug-tests-get-stop-point "make-lambda" "x"))
+   (edebug-set-breakpoint t)
+   (edebug-tests-setup-@ "use-lambda" nil t)
+   (edebug-tests-run-kbd-macro
+    "@g"   (edebug-tests-should-be-at "make-lambda" "x")
+    (edebug-tests-should-match-result-in-messages "1 (#o1, #x1, ?\\C-a)")
+    "g"    (should (equal address@hidden '(11 12 13))))))
+
+(ert-deftest edebug-tests-respects-initial-mode ()
+  "Edebug can stop first at breakpoint instead of first instrumented function."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "fac" '(4) t)
+   (goto-char (edebug-tests-get-stop-point "fac" "mult"))
+   (edebug-set-breakpoint t)
+   (setq edebug-initial-mode 'go)
+   (edebug-tests-run-kbd-macro
+    "@"    (edebug-tests-should-be-at "fac" "mult")
+    (edebug-tests-should-match-result-in-messages "1 (#o1, #x1, ?\\C-a)")
+    "G"    (should (equal address@hidden 24)))))
+
+(ert-deftest edebug-tests-step-through-non-definition ()
+  "Edebug can step through a non-defining form."
+  (edebug-tests-with-normal-env
+   (goto-char (edebug-tests-get-stop-point "try-flavors" "end-unless"))
+   (edebug-tests-run-kbd-macro
+    "C-u C-M-x"
+    "SPC SPC" (edebug-tests-should-be-at "try-flavors" "nutty")
+    (edebug-tests-should-match-result-in-messages "nil")
+    "SPC"     (edebug-tests-should-be-at "try-flavors" "setq")
+    "f"       (edebug-tests-should-be-at "try-flavors" "end-setq")
+    (edebug-tests-should-match-result-in-messages "\"chocolate\"")
+    "g")))
+
+(ert-deftest edebug-tests-conditional-breakpoints-can-use-lexical-variables ()
+  "Edebug can set a conditional breakpoint using a lexical variable. Bug#12685"
+  (edebug-tests-with-normal-env
+   (should lexical-binding)
+   (edebug-tests-setup-@ "fac" '(5) t)
+   (edebug-tests-run-kbd-macro
+    "@"  (edebug-tests-should-be-at "fac" "start")
+    ;; Set conditional breakpoint at end of next line.
+    "C-n C-e x (eql SPC n SPC 3) RET"
+    "g"  (edebug-tests-should-be-at "fac" "mult")
+    (edebug-tests-should-match-result-in-messages
+     "6 (#o6, #x6, ?\\C-f)"))))
+
+(ert-deftest edebug-tests-writable-buffer-state-is-preserved ()
+  "On Edebug exit writable buffers are still writable (Bug#14144)."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "choices" '(0) t)
+   (read-only-mode -1)
+   (edebug-tests-run-kbd-macro
+    "@g" (should (equal address@hidden "zero")))
+   (barf-if-buffer-read-only)))
+
+(ert-deftest edebug-tests-list-containing-empty-string-result-printing ()
+  "Edebug correctly prints a list containing only an empty string (Bug#17934)."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "empty-string-list" nil t)
+   (edebug-tests-run-kbd-macro
+    "@ SPC"  (edebug-tests-should-be-at
+              "empty-string-list" "step")
+    (edebug-tests-should-match-result-in-messages "(\"\")")
+    "g")))
+
+(ert-deftest edebug-tests-evaluation-of-current-buffer-bug-19611 ()
+  "Edebug can evaluate `current-buffer' in correct context. (Bug#19611)."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "current-buffer" nil t)
+   (edebug-tests-run-kbd-macro
+    "@"    (edebug-tests-should-be-at
+            "current-buffer" "start")
+    "SPC SPC SPC" (edebug-tests-should-be-at
+                   "current-buffer" "body")
+    "e (current-buffer) RET"
+    ;; Edebug just prints the result without "Result:"
+    (should (string-match-p
+             (regexp-quote "*edebug-test-code-buffer*")
+             edebug-tests-messages))
+    "g"    (should (equal address@hidden
+                          "current-buffer: *edebug-test-code-buffer*")))))
+
+(ert-deftest edebug-tests-trivial-backquote ()
+  "Edebug can instrument a trivial backquote expression (Bug#23651)."
+  (edebug-tests-with-normal-env
+   (read-only-mode -1)
+   (delete-region (point-min) (point-max))
+   (insert  "`1")
+   (read-only-mode)
+   (edebug-eval-defun nil)
+   (should (string-match-p (regexp-quote "1 (#o1, #x1, ?\\C-a)")
+                           edebug-tests-messages))
+   (setq edebug-tests-messages "")
+
+   (setq edebug-initial-mode 'go)
+   ;; In Bug#23651 Edebug would hang reading `1.
+   (edebug-eval-defun t)))
+
+(ert-deftest edebug-tests-trivial-comma ()
+  "Edebug can read a trivial comma expression (Bug#23651)."
+  (edebug-tests-with-normal-env
+   (read-only-mode -1)
+   (delete-region (point-min) (point-max))
+   (insert  ",1")
+   (read-only-mode)
+   (should-error (edebug-eval-defun t))))
+
+(ert-deftest edebug-tests-circular-read-syntax ()
+  "Edebug can instrument code using circular read object syntax (Bug#23660)."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "circular-read-syntax" nil t)
+   (edebug-tests-run-kbd-macro
+    "@"  (should (eql (car address@hidden)
+                      (cdr address@hidden))))))
+
+(ert-deftest edebug-tests-hash-read-syntax ()
+  "Edebug can instrument code which uses # read syntax (Bug#25068)."
+  (edebug-tests-with-normal-env
+   (edebug-tests-setup-@ "hash-read-syntax" nil t)
+   (edebug-tests-run-kbd-macro
+    "@g"  (should (equal address@hidden
+                         '(#("abcd" 1 3 (face italic)) 511))))))
+
+(provide 'edebug-tests)
+;;; edebug-tests.el ends here
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index ef216c3..285a884 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -363,7 +363,8 @@ be invoked with the right arguments."
     (should-not (make-directory subdir1))
     (should-not (make-directory subdir2 t))
     (should-error (make-directory a/b))
-    (should-not (make-directory a/b t))))
+    (should-not (make-directory a/b t))
+    (delete-directory dir 'recursive)))
 
 (ert-deftest files-test-no-file-write-contents ()
   "Test that `write-contents-functions' permits saving a file.
@@ -393,5 +394,22 @@ name (Bug#28412)."
         (should (null (save-buffer)))
         (should (eq (buffer-size) 1))))))
 
+(ert-deftest files-tests--copy-directory ()
+  (let* ((dir (make-temp-file "files-mkdir-test" t))
+        (dirname (file-name-as-directory dir))
+        (source (concat dirname "source"))
+        (dest (concat dirname "dest/new/directory/"))
+        (file (concat (file-name-as-directory source) "file"))
+        (source2 (concat dirname "source2"))
+        (dest2 (concat dirname "dest/new2")))
+    (make-directory source)
+    (write-region "" nil file)
+    (copy-directory source dest t t t)
+    (should (file-exists-p (concat dest "file")))
+    (make-directory (concat (file-name-as-directory source2) "a") t)
+    (copy-directory source2 dest2)
+    (should (file-directory-p (concat (file-name-as-directory dest2) "a")))
+    (delete-directory dir 'recursive)))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here
diff --git a/test/lisp/ibuffer-tests.el b/test/lisp/ibuffer-tests.el
index d65acf6..35605ca 100644
--- a/test/lisp/ibuffer-tests.el
+++ b/test/lisp/ibuffer-tests.el
@@ -456,11 +456,14 @@
                (funcall create-non-file-buffer "ibuf-test-8a"
                         :mode #'artist-mode))
               (bufB (funcall create-non-file-buffer "*ibuf-test-8b*" :size 32))
-              (bufC (funcall create-file-buffer "ibuf-test8c" :suffix "*"
-                             :size 64))
-              (bufD (funcall create-file-buffer "*ibuf-test8d" :size 128))
-              (bufE (funcall create-file-buffer "*ibuf-test8e" :suffix "*<2>"
-                             :size 16))
+              (bufC (or (memq system-type '(ms-dos windows-nt))
+                        (funcall create-file-buffer "ibuf-test8c" :suffix "*"
+                                 :size 64)))
+              (bufD (or (memq system-type '(ms-dos windows-nt))
+                        (funcall create-file-buffer "*ibuf-test8d" :size 128)))
+              (bufE (or (memq system-type '(ms-dos windows-nt))
+                        (funcall create-file-buffer "*ibuf-test8e"
+                                 :suffix "*<2>" :size 16)))
               (bufF (and (funcall create-non-file-buffer "*ibuf-test8f*")
                          (funcall create-non-file-buffer "*ibuf-test8f*"
                                   :size 8))))
@@ -479,22 +482,28 @@
                                (name . "test.*8b")
                                (size-gt . 31)
                                (not visiting-file)))))
-          (should (ibuffer-included-in-filters-p
-                   bufC '((and (not (starred-name))
-                               (visiting-file)
-                               (name . "8c[^*]*\\*")
-                               (size-lt . 65)))))
-          (should (ibuffer-included-in-filters-p
-                   bufD '((and (not (starred-name))
-                               (visiting-file)
-                               (name . "\\`\\*.*test8d")
-                               (size-lt . 129)
-                               (size-gt . 127)))))
-          (should (ibuffer-included-in-filters-p
-                   bufE '((and (starred-name)
-                               (visiting-file)
-                               (name . "8e.*?\\*<[[:digit:]]+>")
-                               (size-gt . 10)))))
+          ;; MS-DOS and MS-Windows don't allow "*" in file names.
+          (or (memq system-type '(ms-dos windows-nt))
+              (should (ibuffer-included-in-filters-p
+                       bufC '((and (not (starred-name))
+                                   (visiting-file)
+                                   (name . "8c[^*]*\\*")
+                                   (size-lt . 65))))))
+          ;; MS-DOS and MS-Windows don't allow "*" in file names.
+          (or (memq system-type '(ms-dos windows-nt))
+              (should (ibuffer-included-in-filters-p
+                       bufD '((and (not (starred-name))
+                                   (visiting-file)
+                                   (name . "\\`\\*.*test8d")
+                                   (size-lt . 129)
+                                   (size-gt . 127))))))
+          ;; MS-DOS and MS-Windows don't allow "*" in file names.
+          (or (memq system-type '(ms-dos windows-nt))
+              (should (ibuffer-included-in-filters-p
+                       bufE '((and (starred-name)
+                                   (visiting-file)
+                                   (name . "8e.*?\\*<[[:digit:]]+>")
+                                   (size-gt . 10))))))
           (should (ibuffer-included-in-filters-p
                    bufF '((and (starred-name)
                                (not (visiting-file))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index e851530..bfdc301 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2653,8 +2653,9 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
           (tmp-name1 (tramp--test-make-temp-name nil quoted))
           (tmp-name2 (tramp--test-make-temp-name nil quoted))
           (tmp-name3 (tramp--test-make-temp-name 'local quoted))
-          (tmp-name4 (tramp--test-make-temp-name nil quoted)))
-
+          (tmp-name4 (tramp--test-make-temp-name nil quoted))
+          (tmp-name5
+           (expand-file-name (file-name-nondirectory tmp-name1) tmp-name4)))
       ;; Check `make-symbolic-link'.
       (unwind-protect
          (tramp--test-ignore-make-symbolic-link-error
@@ -2716,9 +2717,11 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              (funcall
               (if quoted 'tramp-compat-file-name-unquote 'identity)
               (file-remote-p tmp-name1 'localname))
-             (file-symlink-p
-              (expand-file-name
-               (file-name-nondirectory tmp-name1) tmp-name4)))))
+             (file-symlink-p tmp-name5)))
+           ;; `smbclient' does not show symlinks in directories, so
+           ;; we cannot delete a non-empty directory.  We delete the
+           ;; file explicitely.
+           (delete-file tmp-name5))
 
        ;; Cleanup.
        (ignore-errors
@@ -2737,7 +2740,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (should-error
             (add-name-to-file tmp-name1 tmp-name2)
             :type 'file-already-exists)
-           ;; number means interactive case.
+           ;; A number means interactive case.
            (cl-letf (((symbol-function 'yes-or-no-p) 'ignore))
              (should-error
               (add-name-to-file tmp-name1 tmp-name2 0)
@@ -3193,15 +3196,13 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
          (should (processp proc))
          (should (process-live-p proc))
          (should (equal (process-status proc) 'run))
+         (should (numberp (process-get proc 'remote-pid)))
          (should (interrupt-process proc))
          ;; Let the process accept the interrupt.
           (accept-process-output proc 1 nil 0)
          (should-not (process-live-p proc))
-         (should (equal (process-status proc) 'signal))
          ;; An interrupted process cannot be interrupted, again.
-         ;; Does not work reliable.
-         ;; (should-error (interrupt-process proc) :type 'error))
-         )
+         (should-error (interrupt-process proc) :type 'error))
 
       ;; Cleanup.
       (ignore-errors (delete-process proc)))))
@@ -3477,7 +3478,6 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
   (skip-unless (tramp--test-enabled))
   (skip-unless (tramp--test-sh-p))
 
-  ;; TODO: This test fails.
   (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil)))
     (let* ((default-directory tramp-test-temporary-file-directory)
           (tmp-name1 (tramp--test-make-temp-name nil quoted))
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index ac9e2df..a68688e 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -300,6 +300,12 @@ cf. Bug#25477."
       (setq res (read-passwd "pass: " 'confirm (mapconcat #'string default 
"")))
       (should (string= default res)))))
 
+(ert-deftest subr-tests--gensym ()
+  "Test `gensym' behavior."
+  (should (equal (symbol-name (let ((gensym-counter 0)) (gensym)))
+                 "g0"))
+  (should (eq (string-to-char (symbol-name (gensym))) ?g))
+  (should (eq (string-to-char (symbol-name (gensym "X"))) ?X)))
 
 (provide 'subr-tests)
 ;;; subr-tests.el ends here
diff --git a/test/lisp/vc/smerge-mode-tests.el 
b/test/lisp/vc/smerge-mode-tests.el
index 204a4b9..10d0906 100644
--- a/test/lisp/vc/smerge-mode-tests.el
+++ b/test/lisp/vc/smerge-mode-tests.el
@@ -15,7 +15,7 @@
 ;; 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 <http://www.gnu.org/licenses/>.
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
 
 ;;; Code:
 
diff --git a/test/lisp/xdg-tests.el b/test/lisp/xdg-tests.el
index e3c9a74..b80f5e8 100644
--- a/test/lisp/xdg-tests.el
+++ b/test/lisp/xdg-tests.el
@@ -42,9 +42,6 @@
     (should (equal "frobnicate" (gethash "Exec" tab2))))
   (should-error
    (xdg-desktop-read-file
-    (expand-file-name "wrong.desktop" xdg-tests-data-dir)))
-  (should-error
-   (xdg-desktop-read-file
     (expand-file-name "malformed.desktop" xdg-tests-data-dir)))
   (let ((tab (xdg-desktop-read-file
               (expand-file-name "l10n.desktop" xdg-tests-data-dir)))
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 5dc2634..8de8c14 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -101,7 +101,11 @@
   (should (= 3 (apply #'min '(3 8 3))))
   (should-error (min 9 8 'foo))
   (should-error (min (make-marker)))
-  (should (eql 1 (min (point-min-marker) 1))))
+  (should (eql 1 (min (point-min-marker) 1)))
+  (should (isnan (min 0.0e+NaN)))
+  (should (isnan (min 0.0e+NaN 1 2)))
+  (should (isnan (min 1.0 0.0e+NaN)))
+  (should (isnan (min 1.0 0.0e+NaN 1.1))))
 
 ;; Bool vector tests.  Compactly represent bool vectors as hex
 ;; strings.
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 1c3fde8..70dc937 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -166,6 +166,14 @@
     (should (string-equal
              (format-time-string format look '(-28800 "PST"))
              "1972-06-30 15:59:59.999 -0800 (PST)"))
+    ;; Negative UTC offset, as a Lisp integer.
+    (should (string-equal
+             (format-time-string format look -28800)
+             ;; MS-Windows build replaces unrecognizable TZ values,
+             ;; such as "-08", with "ZZZ".
+             (if (eq system-type 'windows-nt)
+                 "1972-06-30 15:59:59.999 -0800 (ZZZ)"
+               "1972-06-30 15:59:59.999 -0800 (-08)")))
     ;; Positive UTC offset that is not an hour multiple, as a string.
     (should (string-equal
              (format-time-string format look "IST-5:30")
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index a56fb44..01c280d 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -35,6 +35,8 @@
               (char 0))
           (while (and (not failure) (< char 127))
             (setq char (1+ char))
+            (when (and (eq system-type 'cygwin) (eq char 92))
+              (setq char (1+ char)))
             (setq failure (try-link (string char) link)))
           (or failure
               (try-link "/:" link)))
diff --git a/test/src/lcms-tests.el b/test/src/lcms-tests.el
index 3d0942c..d6d1d16 100644
--- a/test/src/lcms-tests.el
+++ b/test/src/lcms-tests.el
@@ -21,9 +21,11 @@
 
 ;;; Commentary:
 
-;; Some "exact" values computed using the colorspacious python library
-;; written by Nathaniel J. Smith.  See
-;; https://colorspacious.readthedocs.io/en/v1.1.0/
+;; Some reference values computed using the colorspacious python
+;; library, assimilated from its test suite, or adopted from its
+;; aggregation of gold values.
+;; See https://colorspacious.readthedocs.io/en/v1.1.0/ and
+;; https://github.com/njsmith/colorspacious
 
 ;; Other references:
 ;; 
http://www.babelcolor.com/index_htm_files/A%20review%20of%20RGB%20color%20spaces.pdf
@@ -49,6 +51,11 @@ B is considered the exact value."
         (lcms-approx-p a2 b2 delta)
         (lcms-approx-p a3 b3 delta))))
 
+(defun lcms-rgb255->xyz (rgb)
+  "Return XYZ tristimulus values corresponding to RGB."
+  (let ((rgb1 (mapcar (lambda (x) (/ x 255.0)) rgb)))
+    (apply #'color-srgb-to-xyz rgb1)))
+
 (ert-deftest lcms-cri-cam02-ucs ()
   "Test use of `lcms-cam02-ucs'."
   (skip-unless (featurep 'lcms2))
@@ -56,8 +63,8 @@ B is considered the exact value."
   (should-error (lcms-cam02-ucs '(0 0 0) 'error))
   (should-not
    (lcms-approx-p
-    (let ((lcms-d65-xyz '(0.44757 1.0 0.40745)))
-      (lcms-cam02-ucs '(0.5 0.5 0.5) '(0 0 0)))
+    (let ((wp '(0.44757 1.0 0.40745)))
+      (lcms-cam02-ucs '(0.5 0.5 0.5) '(0 0 0) wp))
     (lcms-cam02-ucs '(0.5 0.5 0.5) '(0 0 0))))
   (should (eql 0.0 (lcms-cam02-ucs '(0.5 0.5 0.5) '(0.5 0.5 0.5))))
   (should
@@ -87,4 +94,24 @@ B is considered the exact value."
     (apply #'color-xyz-to-xyy (lcms-temp->white-point 7504))
     '(0.29902 0.31485 1.0))))
 
+(ert-deftest lcms-dE-cam02-ucs-silver ()
+  "Test CRI-CAM02-UCS deltaE metric values from colorspacious."
+  (skip-unless (featurep 'lcms2))
+  (should
+   (lcms-approx-p
+    (lcms-cam02-ucs (lcms-rgb255->xyz '(173 52 52))
+                    (lcms-rgb255->xyz '(59 120 51))
+                    lcms-colorspacious-d65
+                    (list 20 (/ 64 float-pi 5) 1 1))
+    44.698469808449964
+    0.03))
+  (should
+   (lcms-approx-p
+    (lcms-cam02-ucs (lcms-rgb255->xyz '(69 100 52))
+                    (lcms-rgb255->xyz '(59 120 51))
+                    lcms-colorspacious-d65
+                    (list 20 (/ 64 float-pi 5) 1 1))
+    8.503323264883667
+    0.04)))
+
 ;;; lcms-tests.el ends here



reply via email to

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